2009-10-18

#0AFFFF

Common Lisp is a wonderfully complex language, and probably no matter how long you've been studying it, you'll always find a thing you didn't know before.

What, for example, do you think #0AFFFF represents?

Perhaps you're thinking of the color turquoise represented as a hexadecimal RGB value?

Well, witness for yourself:
CL-USER> (setf *read-base* 16)
16

CL-USER> #0AFFFF
#0A65535
(Bonus point if you know how to restore *READ-BASE* to a value of 10 again.)

Still no idea?
CL-USER> (type-of *)
(SIMPLE-ARRAY T NIL)
Right, #0AFOO is literal syntax for (make-array nil :initial-element 'foo).

And, yeah, even though Common Lisp is surely a complex beast, it's at the same time very well engineered. Witness thus:
CL-USER> (defvar *a*
           (make-array nil :initial-element 41))
*A*
CL-USER> (incf (aref *a*))
42
CL-USER> *a*
#0A42
And if you want to see really quirky stuff, take a look at strings with an element-type of nil.

No comments: