tur/sym
stdlib/sym.tur
first-class interned runtime symbols (:Sym).
Example
(sym->str :hello) ; => "hello" (sym=? :a :a) ; => true
Since: Phase SYM4
defn
sym->str
(sym->str [s : Sym] :)
return the embedded name of a symbol (no allocation).
Parameters
| s | the symbol whose name to read |
Returns
The NUL-terminated UTF-8 name, without the leading colon.
Example
(sym->str :hello) ; => "hello"
Since: Phase SYM4
defn
sym
(sym [a : Sym b : Sym] :)
pointer-identity equality of two symbols.
Parameters
| a | the first symbol | |
| b | the second symbol |
Returns
true iff a and b are the same interned symbol.
Example
(sym=? :a :a) ; => true (sym=? :a :b) ; => false
Since: Phase SYM4
definstance
Eq[Sym]
(definstance Eq [Sym])
equality on interned symbols: pointer identity.
definstance
Hash[Sym]
(definstance Hash [Sym])
hash a symbol via its precomputed hash field (a single load).
definstance
MapKey[Sym]
(definstance MapKey [Sym])
interned-symbol pointer carrier. Symbols are deduplicated,