-
Notifications
You must be signed in to change notification settings - Fork 4
symbol
Turtle Kitty edited this page Aug 9, 2015
·
5 revisions
A symbol is an interned string of runes - like a text, but without quotes.
They are used as identifiers for variables and object methods.
When used naked in code, they name another object.
When quoted, they name themselves.
Due to the dot operator and symbolic module paths, neither periods (.) nor slashes (/) can be used in symbols. Well... slashes can, but then the dot operator won't work on that symbol.
(def foo 7)
(sys.print foo) -> 7
(sys.print (quote foo)) -> foo
(sys.print 'foo) -> foo
(symbol? x)
(def foo 7)
(symbol? foo) -> false (the unquoted symbol foo is evaluated, returning 7)
(symbol? (quote foo)) -> true
(symbol? 'foo) -> true
(symbol? "foo") -> false
(symbol? 'x) -> true
(symbol? $x) -> false
(symbol? 1) -> false
x.type -> symbol
x.view -> x
x.to-bool -> true
x.to-text -> text version of x: foo -> "foo"