[ENH] Lispy list functions

Peter Smet peter.smet at flinders.edu.au
Wed Sep 8 23:55:20 UTC 1999


This looks handy,

One comment. In prolog, scheme, lisp etc, the head
always returns a single element, and the tail always returns
a list (and nil is an empty list). It looks like your list tail sometimes
returns lists, and sometimes single elements (when there is
only one item left). Won't you then have to continually test
what tail has returned (or am I reading your examples wrong?)

list listTail ifCollection do: [this]
list listTail ifAtomic do: [that]

I think the lisp community has got this right - you can program
to a simpler interface if you know tail always returns a list...

The other thought - what happens if the last element in the collection
is nil? A client will assume that there were no more elements and ignore
the nil, when it is in fact the final member of the list. 
Should lispy collections be allowed to contain nil?

Peter


>list := #(1 2). "(1 2)" "(setq list '(1 2))"
>list listHead. "1" "(car list)"
>list listTail. "2" "(cdr list)"
> "In Lisp this would be (2)!"
>"Now list construction"
>list := nil.
>list listHead. "nil"
>list listTail. "nil"
>list := list listHead: 1. "1" "(setq list (cons 1 list))"





More information about the Squeak-dev mailing list