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

Re: CAR of NIL



The usefulness of CAR and CDR of NIL may depend upon the dialect.  In
Interlisp and R/UCI Lisp it allows one to pretend that data structures,
including function calls, have components that they do not in fact have.
E.g. at least in R/UCI Lisp, optional arguments fall out automatically
from this convention.  Suppose FOO has two arguments, but you call (FOO
A).  When the interpeter or compiler attempts to find the second
argument, they get NIL, because (CADDR '(FOO A)) is NIL under the (CAR
NIL) = NIL, (CDR NIL) = NIL rule.  This has the effect of making NIL an
automatic default value.  In practice this works most of the time, and
avoids a fair amount of hair in implementing real default values and
optional args.  Similar things can be done with user data structures.
It seems fairly clear to me that if (CDR NIL) is to be NIL, (CAR NIL)
must be also, since typically what you really want is that (CADR NIL),
(CADDR NIL), etc., should be NIL. Whether all of this is as important in
MAClisp is less clear.  MAClisp allows explicit declaration of optional
arguments, and if they are not declared, then presumably we want to
treat missing args as errors.  Similarly, Common Lisp will have much
more flexible record structures than the old R/UCI Lisp did (though
Interlisp of course has similar features). It seems to me that if people
write programs using the modern structuring concepts available in Common
Lisp, CAR and CDR NIL will again not be necessary for user data
structures.  Thus as an attempt to find errors as soon as possible, one
might prefer it to be considered an error. It is my impression that CAR
and CDR NIL are being suggested to help compatibility with existing
implementatins, and that *VERY* large amounts of code that depend upon
it.  One would probably not do it if designing from scratch.

-------