You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a new runtime type system, containing the base types (such as str, num, null etc.) implemented using objects extending a Type parent class. These base types should also be referenceable, such as num, which should return its type object if referenced using the identifier num.
This would allow the typeof function to be implemented in a way, where, unlike JavaScript, actual type objects are returned which can be used to check the type of a value. For example:
Getting the type of a value:
typeof(1)// Type 'num'
Comparing the type of a value with a runtime type:
typeof(1)==num// -> true
This would allow the type objects to be used as a unique way to represent runtime types, unlike JavaScript where a string is used to describe the type of a value. Furthermore, this would provide a way to go around the behaviour of JavaScript and ensure type cohesion in the type system of Kipper that is built on top of JavaScript.
This will also mean certain behaviour might be different, such as the JavaScript behaviour that makes null be considered of type "object" when checked using the JavaScript typeof operator.
Exact behaviour / changes you want
Implement parent class Type, which will represent a runtime type.
Implement runtime type objects, which will exist during runtime and can be referenced in Kipper code using their identifier.
Implemented new function typeof(EXP) which will return the type in the form of a type object.
Luna-Klatzer
changed the title
[Feature] Implement built-in Kipper types objects and function typeof which returns a type object
[Feature] Implement built-in Kipper types objects and function typeofDec 7, 2022
Is there an existing proposal for this?
This feature does not exist in the latest version
Proposal
Implement a new runtime type system, containing the base types (such as
str
,num
,null
etc.) implemented using objects extending aType
parent class. These base types should also be referenceable, such asnum
, which should return its type object if referenced using the identifiernum
.This would allow the
typeof
function to be implemented in a way, where, unlike JavaScript, actual type objects are returned which can be used to check the type of a value. For example:Getting the type of a value:
Comparing the type of a value with a runtime type:
This would allow the type objects to be used as a unique way to represent runtime types, unlike JavaScript where a string is used to describe the type of a value. Furthermore, this would provide a way to go around the behaviour of JavaScript and ensure type cohesion in the type system of Kipper that is built on top of JavaScript.
This will also mean certain behaviour might be different, such as the JavaScript behaviour that makes
null
be considered of type"object"
when checked using the JavaScripttypeof
operator.Exact behaviour / changes you want
Type
, which will represent a runtime type.typeof(EXP)
which will return the type in the form of a type object.Additional Notes
The text was updated successfully, but these errors were encountered: