The type-name prefix convention and LIST-...
Olin Shivers 20 Feb 1999 00:25 UTC
From: "Sergei Egorov" <xxxxxx@informaxinc.com>
Date: Fri, 19 Feb 1999 15:22:43 -0500
Does this proposal imply that (LENGTH "abc") and (LENGTH '#(a b c)) return
0? If it does, it will conflict with probably more 'natural' attempts to
generalize LENGTH to accept other kinds of sequences. Calling it
LIST-LENGTH does not affect existing programs and does not introduce any
potential conflicts.
You can't fix this issue by simply changing the name LENGTH to LIST-LENGTH,
because it is pervasive throughout list-lib. You would have to change the
names of all these procedures:
first second third fourth fifth sixth seventh eighth ninth tenth
take drop take! drop! last (times 2, most likely, if we split these l/r)
zip unzip2 unzip3 unzip4 unzip5
append! reverse-append reverse-append!
unfold unfold/tail foldl foldr reducel reducer
append-map append-map! map! filter-map map-in-order
filter partition remove
filter! partition! remove!
find any every
del delq delv delete
del! delq! delv! delete!
mem ass
delq-duplicates delv-duplicates delete-duplicates del-duplicates
delq-duplicates! delv-duplicates! delete-duplicates! del-duplicates!
reverse!
append reverse
member memq memv assoc assq assv
map for-each
Any future generalisation of these functions to some sort of "sequence generic"
functions or OO messages will have to postulate an alternate module binding
these names to the generic functions/messages. I'd suggest that such a spec
would come in two parts: a spec for the new library, and a spec giving an
alternate set of bindings for the list-lib procs.
But this is really outside the bounds of this SRFI. I'm not willing to
pervasively tack "LIST-" onto the front of all these names; it would lard
up the names too much and would also break with current code practice in
what seems to me to be gratuitous fashion.
Even with LIST-LENGTH, I still think that the proposed terminology shift
is not justified in general LISP/Scheme context. The fact that
(LIST-LENGTH 5) returns 0 makes you expect (LIST? 5) to return #t
etc. What was wrong with IMPROPER-LIST?
Yes, this is a good point. If you have the notion that everything is a list,
then any procedure named LIST? that isn't (LAMBDA (X) #t) is probably going
to cause some confusion. This is exactly why my "Everything is a list"
msg proposed these three predicates, which *aren't* misleading in this
context:
circular-list? x -> boolean
proper-list? x -> boolean
dotted-list? x -> boolean
IMPROPER-LIST? is a perfectly fine thing. It's either of these:
(conjunction circular-list? dotted-list?)
(negate proper-list?)
Given that PROPER-LIST? exists, is it important to define IMPROPER-LIST?
Just to reiterate, I am now proposing to punt LIST? for exactly this reason,
in favor of PROPER-LIST?, CIRCULAR-LIST?, DOTTED-LIST?.
-Olin