Skip to content

Symbols #51

@Victorious3

Description

@Victorious3

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions