Symbols / Keywords
Like most Lisp's Nujel supports symbols as well as keywords. In general they are very similar to Scheme, so much that some SRFI's have been implemented as is.
Warning
It is adviced not to use periods (.
) as well as forward and backward slashes (/
, \
) in symbols interned by the reader directly, this is because these characters will very likely become used in reader macros in the future.
1. Symbols
Symbols in Nujel behave pretty much the same as in most other Lisps, in that they are implictly looked up unless quoted.
asd ; Every symbol is implicitly looked up, with an exception thrown on failure ; => :unbound-variable 'asd ; By quoting a symbol this implicit look up can be disabled asd (string->symbol "asd") ; You can also turn any old string into a symbol, this is sometimes called interning a string asd (== 'asd (string->symbol "asd")) ; The two values actually point to the same underlying data structure #t
Implementation detail
Currently symbols are truncated after 63 characters, this limit hasn't been much of a problem yet but it will be addressed when it becomes necessary.
2. Keywords
Since quoting can become quite tedious there is another very similar data type, keywords. They share most functionality with symbols with the main difference being that they will not be implicitly looked up.
By pre- or suffixing a symbol with a :
the reader will return a keywords.
:asd ; A keyword :asd asd: ; Another keyword asd: (= asd: :asd) ; It doesn't matter where we put the colon #t (= :asd (symbol->keyword 'asd)) #t
3. Usage
Regarding their usage, keywords should be used when the keyword itself has a useful meaning, symbols should be used to label other values which could work just as well with another symbol associated.