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 support for built-in type identifiers such as str, num, bool etc. #495

Open
2 of 5 tasks
Luna-Klatzer opened this issue Jul 27, 2023 · 0 comments
Open
2 of 5 tasks
Assignees
Labels
feature New feature or enhancement
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Luna-Klatzer commented Jul 27, 2023

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 support for type identifiers, which should be usable during runtime to compare types.

This includes the following types:

  • bool
  • str
  • num

But importantly excludes the following types, as they are constants and therefore have as the type themselves. This also means doing typeof(<value of type undefined>) will simply return undefined and therefore should be rather replaced with <value of type undefined> == undefined (Same as with null and void, which is effectively a synonym for undefined.

This extends proposal #369, which proposes support for the built-in typeof() function allowing dynamic type checking.

Exact behaviour / changes you want

  • Implement runtime type objects for the Kipper base primitive types str, num and bool.
  • Add support for comparisons using typeof(EXP) and the constant type identifiers.
  • Allow the identifiers to be assigned to variables using the type type, for example:
    var reflectedType: type = num;
    if (typeof(someVariable) == reflectedType) {
      // It is of type 'num'
      ...
    }
    This also serves as the foundation for future custom types using custom type definitions with interfaces or unions.

Additional Notes

@Luna-Klatzer Luna-Klatzer added the feature New feature or enhancement label Jul 27, 2023
@Luna-Klatzer Luna-Klatzer added this to the v0.11.0 milestone Jul 27, 2023
@Luna-Klatzer Luna-Klatzer self-assigned this Jul 27, 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
Development

No branches or pull requests

1 participant