[armedbear-devel] Read tables

Erik Huelsmann ehuels at gmail.com
Mon Aug 22 19:30:01 UTC 2011


Dear Blake,

Based on your input, I have been thinking more about making my
> interface case sensitive.  It would be better.  After doing a little
> research I tried:
>
>        (setf (readtable-case *readtable*) :invert)
>
> This seems to have made all the standard stuff ("car, cons, etc.")
> lowercase as I'd prefer.  After that I tried creating lists:
>
>         (setq x '(HELLO There how))
>
> and the case seems to be preserved - not inverted.
>
> I also tried things like:
>
> (defun fun (x) (+ 1 x))
> (defun Fun (x) (+ 2 x))
> (defun FUN (x) (+ 3 x))
>
> And it worked as expected.  I'm a bit confused.  Why aren't symbols
> (as in '(HELLO There how)) inverted?  (I understand that :invert
> doesn't change case on mixed case symbols but then all upper or all
> lower should be inverted.)  Is *print-case* being affected?
>

*print-case* isn't being affected, but (readtable-case *readtable*) affects
printer output: in order to make expressions readable on printing, the
printer inverts the reader behaviour on *print-readably*.

To see what's really being returned, see the following transcript:

CL-USER(1): (defvar rt (copy-readtable nil))
RT
CL-USER(2): (setf (readtable-case rt) :invert)
:INVERT
CL-USER(3): (let ((*readtable* rt)) (read-from-string "(a A aa aA AA)"))
(A |a| AA |aA| |aa|)

This way, the reader settings applied when printing the READ-FROM-STRING
result are the default reader settings, while the expression is being read
using the :INVERT readtable-case.


> At first test, it seems like :invert does exactly what most people
> want - case sensitive lisp that has system symbols all lower case.
> Are there instances in which this doesn't work?  Will this affect
> lisp-java usage when it comes to case?
>
> Any pointers would be appreciated.
>

See http://www.lispworks.com/documentation/HyperSpec/Body/22_accb.htm for
the effects of READTABLE-CASE on the Lisp printer. You already knew about
the effect of READTABLE-CASE on the lisp reader (
http://www.lispworks.com/documentation/HyperSpec/Body/23_ab.htm).

Hope that helps!

Regards,

Erik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20110822/f0fdd665/attachment.html>


More information about the armedbear-devel mailing list