Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Implement built-in Kipper types objects and function typeof #369

Open
2 of 5 tasks
Luna-Klatzer opened this issue Dec 7, 2022 · 0 comments
Open
2 of 5 tasks
Assignees
Labels
feature New feature or enhancement
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Luna-Klatzer commented Dec 7, 2022

Is there an existing proposal for this?

  • I have searched the existing issues

This feature does not exist in the latest version

  • I am using the latest version

Proposal

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.

Additional Notes

@Luna-Klatzer Luna-Klatzer added the feature New feature or enhancement label Dec 7, 2022
@Luna-Klatzer Luna-Klatzer added this to the Stable Kipper Release milestone Dec 7, 2022
@Luna-Klatzer Luna-Klatzer self-assigned this Dec 7, 2022
@Luna-Klatzer 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 typeof Dec 7, 2022
@Luna-Klatzer Luna-Klatzer modified the milestones: Stable Kipper Release, v0.11.0 Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement
Projects
Status: Under Consideration
Development

No branches or pull requests

1 participant