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 #77

Open
Tracked by #5
liquidev opened this issue Jun 8, 2022 · 0 comments
Open
Tracked by #5

Symbols #77

liquidev opened this issue Jun 8, 2022 · 0 comments
Labels
enhancement New feature or request language feature wishlist @liquidev's feature wishlist

Comments

@liquidev
Copy link
Member

liquidev commented Jun 8, 2022

One neat feature Ruby has is symbols - unique identifiers, where two different symbols with the same name are equal:

p :yes == :yes  # true

I think Mica should get a similar feature, though much less dynamic. Unlike strings, symbols should not cause allocations. Their use case would be similar to enums in statically typed languages. For instance, a LÖVE-like API might use symbols for specifying if rectangles should be filled or outlined:

Graphics.rectangle(:fill, 32, 32, 32, 32)
Graphics.rectangle(:line, 32, 32, 32, 32)

In NaN-tagged mode, symbols should use the unused values of ValueImpl::SIGN_ENUM NaNs - those past nil, false, and true. The values for symbols should be stored in the environment, such that symbols are comparable across all scripts run by the same engine.

@liquidev liquidev added enhancement New feature or request language feature labels Jun 8, 2022
@liquidev liquidev mentioned this issue Jun 8, 2022
11 tasks
@liquidev liquidev moved this to 📦 Backlog in Mica 1.0 Sep 10, 2022
@liquidev liquidev added the wishlist @liquidev's feature wishlist label Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language feature wishlist @liquidev's feature wishlist
Projects
Status: 📦 Backlog
Development

No branches or pull requests

1 participant