elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.52k stars 296 forks source link

Unique symbols #1802

Open xiaq opened 2 months ago

xiaq commented 2 months ago

What new feature should Elvish have?

A way to create a unique symbols, like JavaScript symbols.

The main property of a symbol/keyword is that it's only equal to itself. This makes it useful for modeling domain-specific values, enums, or used as unique keys in maps.

Symbols in lisps serve a similar function but they actually behave more like interned strings. But namespaced keywords in Clojure match the desired semantics.

Output of "elvish -version"

0.21.0-dev.0.20240430145458-c7d81b20a010

Code of Conduct

xiaq commented 2 months ago

Weirdly I couldn't find dedicated docs for namespaced keywords on Clojure's website, but a Google search seems to give some relevant results.