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

Why <empty-list> and <pair>? or More heresy...



All this talk of the lack of a need for <true> and <false> classes has
made me wonder why it is necessary to have an <empty-list> class.  Why
can't people just use `(singleton '())'?  Given that, why even have a
<pair> class?  Programs can distinguish between a <pair> instance and
an <empty-list> instance using the same `(singleton '()).  This change
would definitely simplify the class structure.  Granted, in some cases
programmers might need to employ two methods to flag list arguments
that must be non-empty, such as for `(setter car)', but in most cases
they need to handle '() specially anyway and would be writing a
separate method for it.

It could even be argued that #F should also be used as the bottom
value for <list>.  It seems that the real reason to want to use '() is
so that people can `cdr' and `car' it without first checking and that 

	(instance? '() <list>) => #T 

thereby making declarations easier or no need to resort to 

	(or (singleton #F) <list>)

I like these efficiency features, but if people want symmetry, then
one might consider using #F instead of '().

I actually still prefer automatic void values (changed the name to
avoid collision with the usual connotations of bottom value), where
the void value is an instance of the class and could be customized to
have special properties for efficiency (such as '()).  Programs can
access the void value and use it for singleton dispatching.  This
makes the use of a void value (such as '()) both efficient and
symmetrical.

-- jonathan bachrach

IRCAM
31, rue Saint-Merri
F75004 Paris, France
011-33-1-42772492
bachrach@ircam.fr