Hi Edwin,

> >   +-----+-----+     +-----+-----+
> >   |  a  |  ---+---->|  b  | NIL |
> >   +-----+-----+     +-----+-----+
> 
> thank you for this. clearer now. this is how it is implemented in
> picolisp underneath, right? (from pico.h)

Yes.

> so if i had a different base data structure, it wouldn't be like this?
> say in other lisp implementations?

AFAIK, this is the same in all Lisp implementations since earliest
times. Perhaps with the exception of "CDR-consing" in some Lisps (an
optimization where the CDR part of a cell is omitted, and a single bit
somewhere indicates that the next cell is the immediately following
memory location).



> reason i'm asking is that if i had arrays as base structures in C
> instead of linked cells, a dotted pair would look something like:
> 
> +-----+-----+
> |  s  |  t  |
> +-----+-----+
> 
> and a list as:
> 
> +-----+-----+-----+
> |  s  |  t  | NIL |
> +-----+-----+-----+
> 
> is this a possible way to think about this or am i just chasing windmills?

I think this distinction makes not much sense in C, as there is no
concept of a dotted pair (and also not needed).


In fact, _each_ list consists of dotted pairs, it just happens that the
CDR of each cell in those lists is either another list or NIL. The dot
becomes visible only if the CDR is an atom. Besides that, there's
nothing special about it.

According to Lisp folklore, lists were originally always printed as

   (a . (b . (c . (d . NIL))))

but due to a bug in the printing routine the list showed up as

   (a b c d)

which was found to be nicer. Don't know if this is true, though.

In any case, dotted pairs are the core of picolisp.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to