[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
disjointness of '() and #f
Another factor arguing for disjointness has been raised but unstated for
some time. Disjointness [(eq? '() #f) -> #f] is much easier to explain
to students as it accords with their intuitive notions. There are areas
where Scheme differs from naive intuition for deep reasons (e.g.
exactness). It would be nice to be able to concentrate on areas where
there really are deep issues rather than areas of happenstance.
This comes from a very widespread way of teaching things that will
ultimately lead to confusion about lists and pairs. The problem is
that typically lists are introduced as primitive or quasi-primitive
types and then students get confused when they start playing with both
lists and pairs.
The most consistent way that I've seen to avoid the whole problem
altogether is to do the following (which is the approach mainly
followed in SICP):
Pairs are primitive, lists are not.
cons, car, and cdr operate exclusively on pairs.
As a convention, we build lists on top of them by distinguishing some
arbitrary object as the end of all lists and the empty list. I don't
advocate for this distinguished object to be #f, I just don't want you
to force me to have a magic object just for this purpose. #f happens
to be a convenient such object to choose. It is only a convention
that can be violated at any time.
The confusion comes because the WRITE procedure is byassed towards
lists, and furthermore in some implementations where (eq? '() #f) is
true, #f prints as "()". I think the printer is at fault, since the
essential (not conventional) meaning of this object is as #f, not as
Jinx, if you can explain to my simple self why you cannot redefine a
scheme implementation which follows the standard to do what you want in
this case, please do so. If not, I request that you remove your
You can obviously do the same yourself by redefining all list
operations. The situation is symmetric.
I don't want to force you to make them eq? I just don't want you to
force me to make them distinct.
I thought we had stopped arguing about this one a while ago. Please
let things be.