Francisco Vides Fernández <firstname.lastname@example.org> wrote:
| I'm trying to write something like this:
| (a list of symbols))
| (|a| |list| |of| |symbols|)
| Which basically setf the readtable-case of *readtable* to :preserve ...
| but I'd like something cleaner, if possible. Some suggestions?
Others have given you good answers, but depending on exactly what
you're trying to accomplish, you might want to take a close look
at :INVERT rather than :PRESERVE. Assuming your source code is all
lowercase, you can (setf (readtable-case *readtable*) :invert) and
*leave* it that way, and still preserve CamelCase:
> (readtable-case *readtable*)
> (setf (readtable-case *readtable*) :invert)
> '(A List Of Symbols such as FOO & BAR)
(A List Of Symbols such as FOO & BAR)
> (mapcar #'symbol-name *) ; Show the "real" internal case
("a" "List" "Of" "Symbols" "SUCH" "AS" "foo" "&" "bar")
> (eq 'foo (intern "FOO")) ; So lowercase source code works
> (eq 'FOO (intern "FOO")) ; but uppercase source doesn't,
> (eq 'FOO (intern "foo")) ; unless you really do want lowercase names.
When readtable-case is :INVERT, the printer also inverts on output
by default. If all you need is read/print invariance of case, :INVERT
may be your friend.
Rob Warnock <email@example.com>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607