Concept for the Kipper Runtime Type System #373
Luna-Klatzer
started this conversation in
Ideas
Replies: 1 comment
-
Important related issues: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Concept for the Kipper Type Runtime System
This is a possible implementation of the Kipper Type Runtime system, which will implement a different behaviour than JavaScript or TypeScript to ensure type cohesion and security.
Primitive Types
Since Kipper is a language that will primarily translate to JavaScript and TypeScript, the type system of Kipper will strictly be limited to the existing primitive types that exist and changes may only add, but not remove any type, since doing otherwise would immediately break any compatibility between Kipper and JS/TS files.
As such, the runtime types of Kipper will simply inherit the behaviour from JavaScript, but extend it with additional functionality using the Kipper Compiler and runtime additions. This means explicitly that Kipper will implement runtime type objects to represent these primitive types, which can also then be referenced in Kipper code using their identifier.
For example, the type identifier used to specify the type of a variable will be the same as the referencable type identifier:
To that, like with the constructors in JavaScript, you may use the types as a way to explicitly convert them to a specified type, for example:
The
Type
parent classTo implement these runtime type objects, a built-in class called
Type
will be implemented, which will provide the standard implementation of a runtime type. This can also then be used as the type for storing a type, like for example:This class will also provide the following fields:
Detailed List of types
null
null
void
undefined
undef
*undefined
num
number
Number
str
string
String
bool
boolean
Boolean
bigint
bigint
BigInt
obj
object
Object
*As of release v0.10.3,
undef
is calledundefined
, but that may change with the next release to simplify the base primitive types to be collectively shorter.Additional Reference
Beta Was this translation helpful? Give feedback.
All reactions