Kipper Runtime Types Proof of Concept #332
Luna-Klatzer
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Possible implementation of runtime types in Kipper. This shows a basic implementation, which can be extended for interface types and custom type definitions.
Source File: https://gist.github.com/Luna-Klatzer/7c920cf8564ac088a798d98fa3357af9
This rough concept is for now only intended as a rough idea of how runtime types might work. Almost definitely when Kipper reaches the stage of development, where these types will be implemented and referencable, the implementation will be more complex/cover more edge cases. To that, the compiler will not just generate function calls to these types for type checking, but still try to optimise away any obvious type comparisons and
typeofcalls. (Unless optimisations are turned off)Still, even with optimisations, such base types will likely always stay in the output files of a Kipper project, since they will be useful for debugging output JavaScript/TypeScript files and in the future, there likely will be also an implementation of a dynamic runtime type generator, which could generate a type object (which can be used with the
EXP match Toperator) during runtime if needed (While this would be horrendous performance-wise on a large scale, it could be useful to avoid having to write type checks for specific objects yourself, especially when parsing JSON or comparison objects. Though obviously, the docs should warn the use of such heavy runtime tasks, unless it's really needed and such types can't be generated during compile-time, like planned with interfaces)Beta Was this translation helpful? Give feedback.
All reactions