Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know if it's part of the spec, but sbcl is actually case-sensitive, just that read upcases everything by default. There's a special syntax if you need to preserve case:

    |this-will-be-read-with-case-preserved|


That's part of Common Lisp. By default the reader is case-insensitive and upcasing -> the internal representation is case-preserving. If we escape characters in a symbol or even the whole symbol, those preserve their case.

But one can for example configure the READER in Common Lisp to use different modes - for example fully case preserving. The built-in CL symbols will stay in uppercase - because that's how they are defined.

  CL-USER 32 > (setf (readtable-case *readtable*) :preserve)
  :PRESERVE

  CL-USER 33 > (DEFUN This-Is-A-Symbol (VarIable)
                 (SIN VarIable))
  This-Is-A-Symbol

  CL-USER 34 > (This-Is-A-Symbol 7.4)
  0.89870817

  CL-USER 35 > (THIS-IS-A-SYMBOL 7.4)

  Error: Undefined operator THIS-IS-A-SYMBOL in form (THIS-IS-A-SYMBOL 7.4).
As you can see, we can then program with case preserved syntax and use the uppercase built-in symbols like DEFUN or SIN.


That syntax is displayed lower down, under "quoted identifier". I think this is an area that "would need more explanation than there is room for". There's also the fact that |white space symbol| and white\ space\ symbol are not actually the same thing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: