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

Symbols #51

Open
Victorious3 opened this issue Jul 20, 2024 · 0 comments
Open

Symbols #51

Victorious3 opened this issue Jul 20, 2024 · 0 comments
Labels
proposal New feature or request

Comments

@Victorious3
Copy link
Contributor

Symbols would look like in ruby: :symbol
The type of a symbol would be essentially the symbol itself, inside of a pseudo type constructor like sym:

let s: sym(:my_symbol) = :my_symbol

You can use the more generic sym type without specifiying a symbol like this:

var s: sym = :my_symbol

Symbols can be combined by using the | operator or by writing literals next to each other:

let s1 = :sym_a
let s2 = :sym_b
let combined = s1 | s2
let combined2 = :sym_a :sym_b

The combination of Symbols can be stored inside the type as well, this would result in a type like this: sym(:sym_a, :sym_b)
You would only be able to combine known Symbols, that is Symbols which have a type like sym(:symbol)
Combined symbols would be factually the same as normal symbols, they also get uniqued so two combinations of symbols will compare equal.

The real power comes when converting these to enums and flag enums. This is TBD.

@Victorious3 Victorious3 added the proposal New feature or request label Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant