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

Re: dotted lists



> StCLtLp30 suggests (a b c . d) is OK, and MCL accepts it, but hits the Listener
> if I try to take its (length).
> 
> Q1: This is a feature, yes? (I gather MCL is pretty solid.)
> 
> Q2: *If* it is a feature, isn't it inconsistent for MCL to *accept* a
> badly-formed (Q2.1: Is it?) quoted list.

The problem is that a "dotted list" is not a list.  In fact, it's not a
sequence, so LENGTH isn't defined on it.  (Though I wouldn't have been
suprised if you said MCL returned 3.)

> I note that (a b c.d) works as advertised.

Yep, because this is a list of length 3.

> I *do* see Steele mentions "In MacLisp, the dot...need not be surrounded by
> white space." The MCL behavior suggests to me "_must_ not be surrounded by
> white space" is the rule here.

Not really.  It's just that these are two different objects.  The first
looks like kinda like this (excuse the ASCII graphics)

              ---------
              | . | . |
              --|---|--
                V   V
                A  ---------
                   | . | . |
                   --|---|--
                     V   V
                     B  ---------
                        | . | . |
                        --|---|--
                          V   V
                          C   D

(where A is the atom with print-name "A", etc.) while the second looks kinda like

              ---------
              | . | . |
              --|---|--
                V   V
                A  ---------
                   | . | . |
                   --|---|--
                     V   V
                     B  ---------
                        | . | / |       [i.e., a cons cell with car the
                        --|------        atom  whose print-name is "C.D"
                          V              and whose cdr is NIL -- in other 
                         C.D             words, a one element list (C.D)]

What Steele meant was that in MacLisp, reading (A B C.D) would produce the
same thing as reading (A B C . D).

> Q3: (curiosity only) I gather MacLisp is unrelated to the Macintosh. Is MCL
> related to/derived from MacLisp in any way?

Yes.  Mac Common Lisp is a Common Lisp, and Common Lisp was defined in
order to help unify the various successors to MacLisp.  There are
important differences between the two -- Common Lisp's use os lexical
scoping, for example -- but MacLisp is recognizably an ancestor of MCL.

> I am freaking out over how magnificent CL is, but I *do* want to understand
> behind the scenes stuff, so Q2 above is very interesting to me.  ...

If you're interested in the internals, the best source is still Allen's
_Anatomy of LISP_.  This pre-dates Common Lisp by a few years, but nothing
newer is as good as an introduction to the basics of Lisp implementation.

                                                        -- rar