No matching definitions.

tur/sym

stdlib/sym.tur

first-class interned runtime symbols (:Sym).

A :Sym value is a non-null pointer to a static, process-lifetime record in .rodata. Two keywords with the same name are the *same pointer*, so equality and hashing are pointer/field operations -- no string compare, no allocation. Requires the -Xsymbols flag, which makes :foo a valid expression of type :Sym.

(sym->str :hello)      ; => "hello"
(sym=? :a :a)          ; => true

Since: Phase SYM4

defn

sym->str

(sym->str [s :Sym] :cstr)

return the embedded name of a symbol (no allocation).

The returned cstr points directly into the symbol's static record, so it shares the symbol's process lifetime and never needs freeing.

sthe symbol whose name to read

The NUL-terminated UTF-8 name, without the leading colon.

(sym->str :hello)  ; => "hello"

Since: Phase SYM4

defn

sym=?

(sym=? [a :Sym b :Sym] :bool)

pointer-identity equality of two symbols.

Because symbols are interned, two :Sym values are equal exactly when they are the same pointer; this is a single compare with no string work. It is a convenience over the Eq[Sym] typeclass instance for code that does not want to dispatch through (eq? ...).

athe first symbol
bthe second symbol

true iff a and b are the same interned symbol.

(sym=? :a :a)  ; => true
(sym=? :a :b)  ; => false

Since: Phase SYM4

definstance

Eq[Sym]

(definstance Eq [Sym])

equality on interned symbols: pointer identity.

Two symbols are equal iff they are the same interned pointer.