[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Car and Cdr of nil is nil



This rather controversial feature was adopted in Maclisp after some
people saw it in Interlisp.  I'm not sure if the Maclisp people thought
it was a good idea, or if they just thought they'd better be compatible
for ease in porting programs.  If a program relies on this feature, it
is often very hard to get it running in a Lisp that doesn't have it.

I'll let the Interlisp people describe the genesis of this feature, but
it's clear what the arguments pro and con are.  On the plus side, this
allows you to use lists as data structures and to truncate any all-NIL
branches without having to put checks for this into the accessors.  So
the programmer (or structure-writing macro) can just write CADDDR, and
get NIL if the data structure is (FOO (SOME LIST)).  On the minus side,
this feature really messes up the type hierarchy and it can create nasty
problems for Lisp implementors on stock hardware -- a lot of trickery is
required if you want CAR and CDR to operate properly and quickly without
having to check for NIL as a special case.

-- Scott