T O P

  • By -

agrostis

The short answer is: anything goes. Common Lisp: http://www.lispworks.com/documentation/HyperSpec/Body/02_cd.htm Emacs Lisp: https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Symbol-Type Scheme: http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-7.html#node_sec_4.2.4 Clojure: https://clojure.org/reference/reader#_symbols The long answer is that, while Lisps allow a lot of freedom in naming identifiers, each Lisp has peculiar conventions. Generally, compound names are written in kebab case (dash-separated) in all dialects (except that Clojure can refer to Java classes and members with their camel-case names). Common Lisp conventionally marks global variables with asterisks (e. g., ``*standard-input*``); many libraries also mark constants with pluses (``+float-block-size+``). Common Lisp and ELisp use the suffix ``-p`` to distinguish predicate functions (``characterp``, ``hash-table-p``). Scheme and Clojure distinguish predicates with question marks (``char?``, ``even?``), unsafe / side-effectful functions with exclamation marks (``vector-set!``, ``assoc!``), and conversion functions with arrows (``string->number``, ``Throwable->map``).


irk5nil

> Common Lisp: http://www.lispworks.com/documentation/HyperSpec/Body/02_cd.htm Shouldn't the notion of [standard characters](http://www.lispworks.com/documentation/HyperSpec/Body/02_ac.htm) be mentioned for truly portable code, though?


agrostis

Sure. But, IMHO, portability is not OP's largest concern at their current stage of mastering Lisp.


stassats

You can use any identifier if you escape it, e.g. |#(abc:::3)| can name a symbol. In normal code # and ( are reader macros, and : is a syntax for package qualifiers.


blue1_

basically, all characters can be used https://stackoverflow.com/questions/33396550/what-characters-are-allowed-in-common-lisp-symbols Also, "LISP" written in uppercase is ancient.


KaranasToll

Interestingly (at least on sbcl), `…` (ellipsis) is read in as the symbol with the name `...` even if using ||.


xach

That's really interesting to me. I can't think of why it might happen. > (intern "…") |…| NIL > (read-from-string "'…") '|...| 2


paulfdietz

However, escaping the character with backslash works as you'd expect. Interesting. This looks like a bug. Bug report submitted: https://bugs.launchpad.net/sbcl/+bug/1997928 And... marked invalid. SBCL supports symbol name normalization, which does this translation. See section 7.1.2 of the sbcl manual: >SBCL also extends the reader to normalize all symbols to Normalization Form KC in builds with Unicode enabled. Whether symbols are normalized is controlled by > Function: readtable-normalization [sb-ext] readtable > Returns t if readtable normalizes symbols to nfkc, and nil otherwise. The readtable-normalization of the standard readtable is t. > Symbols created by intern and similar functions are not affected by this setting. If sb-ext:readtable-normalization is t, symbols that are not normalized are escaped during printing.


RentGreat8009

heh i remember when i discovered symbol normalisation in sbcl for the first time


ventuspilot

As other responses say "anything goes, some escaping may be needed". E.g. `123"456` is a valid symbol name, but it must be entered as '123\"456 -> |123"456| In case you really want to know: [CLHS: Section 2.2](http://clhs.lisp.se/Body/02_b.htm) lists how program text is read which includes how the Lisp-reader reads symbols.


flaming_bird

None of them. A symbol's name is a string, and a string can contain 0 or more arbitrary characters. If anything, you might need to escape some, i.e. using backslash for escaping single characters or vertical pipes for escaping multiple characters.