News for hackers. Stuff that matters.
Re:Strangest Language Features by krzysz00 on Thursday December 15, 2011 @07:42PM (#3358811)
Common Lisp has a global variable called read-base ,which controls also base numbers are read in with. This, IIRC, was put in because some earlier Lisps read numbers in octal, while others used decimal. Setting this variable to something higher than 10 can give you strange results. For example,

    nil
    => NIL
    (eql '() nil)
    => T
    (setf *read-base* 36)
    nil
    => 30477
    (eql '() nil)
    ERROR: 19101 is not a function name; try using a symbol instead
    (|EQL| '() nil)
    => NIL
For you non-lispers, the empty list '() is equal to the "false" value, nil. Also, the pipes are special syntax to allow for symbols which normally not parse as symbols. (The uppercase is for historical reasons too).

The moral of this story: "See that control variable over there, the one that does weird things to parsing? Don't touch it unless you know what you're doing."

Re:Strangest Language Features by RodgerTheGreat on Thursday December 15, 2011 @09:08PM (#3359074)
I presume that CL standardized on a base as a default, though? Otherwise you have an appropriately recursive problem that every base is "base-10" in that base.

edit: (setf read-base (+ 1 1 1 1 1 1 1 1 1 1)) :)

Re:Strangest Language Features by krzysz00 on Thursday December 15, 2011 @09:18PM (#3359102)
I just went and checked, and the standard gives a default value of "10." for read-base , so decimal by default (I think). It also says:

"Notes:

Altering the input radix can be useful when reading data files in special formats. "