[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Ken Tilton <firstname.lastname@example.org>
- Subject: dotted lists
- From: email@example.com (Steve Strassmann)
- Date: Fri, 3 Mar 1995 17:48:31 -0500
- Cc: firstname.lastname@example.org
- Sender: email@example.com
> Date: 03 Mar 95 14:47:15 EST
> From: Ken Tilton <firstname.lastname@example.org>
> To: MCL <email@example.com>
> Subject: dotted lists
> Sender: firstname.lastname@example.org
> Beginner Q...
> 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.)
Yes, that's correct behavior. You're not hitting the Listener, actually,
you're getting the debugger, which talks to you through the Listener.
> Q2: *If* it is a feature, isn't it inconsistent for MCL to *accept* a
> badly-formed (Q2.1: Is it?) quoted list.
A dotted list isn't technically a proper list. Rather than quibbling over
lofty philosophical ideals like 'good' and 'bad', we just say that you can
use the dot notation as a shortcut for entering a certain kind of data
structure (dotted lists). At the same time, certain operations (like
length) do not work on them.
A list is made up of a daisy chain of objects known as "cons" cells. Each
is sort of like an alligator clip that holds two objects. A proper list is
made by pointing the second part (the CDR) to the next link in the chain,
or else NIL when it gets to the end. LENGTH works by walking down the links
and counting them, and stops when it sees NIL. A dot violates this rule
because the very last CDR points to something other than NIL or another
link. That's the error you got in the debugger.
> I note that (a b c.d) works as advertised.
That's because C.D is a single object, a symbol whose name happens to be
spelled with three characters. This has nothing to do with dotted lists.
> 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.
> Q3: (curiosity only) I gather MacLisp is unrelated to the Macintosh. Is MCL
> related to/derived from MacLisp in any way?
MacLisp's name derives from Project MAC, an MIT research project whose
origins goes back to the 60's. It also gave its name to Macsyma, a symbolic
algebra package - perhaps you know its more recent and relatively more
famous copycat, Mathematica. So Maclisp had at least a decade's head start
before the invention of the Macintosh. Common Lisp was derived from Maclisp
and several other dialects floating around in the early 80's.
By the way, the name "Macsbug" predates the Macintosh as well, it stands
for Motorola something something debugger.
> 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.
> Hang on...maybe the inspector will let me at the cons cells. I would like to
> see what exactly MCL cobbled together.
> Ken Tilton
> Missing Link Software