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

Re: Lexical syntax for boxes

This page is part of the web mail archives of SRFI 111 from before July 7th, 2015. The new archives for SRFI 111 contain all messages, not just those from before July 7th, 2015.

On Tue, May 21, 2013 at 2:17 AM, John Cowan <cowan@xxxxxxxxxxxxxxxx> wrote:
> Alan Watson scripsit:
>> Defining `equal?` on boxes to be more like `equal?` on vectors of
>> length 1 would be more useful, I think.
> It might or it might not be, depending on one's needs.  You might want
> `equal?` to look right through boxes, or you might want to insist that
> boxes are `equal?` only if they are `eqv?`.  That's why a generalized
> equality predicate that can, but need not, descend into various things
> is so useful: you can tailor it to your needs and easily create your own
> best equality predicate(s) for each new circumstance.  That allows the
> exact details of what `equal?` does to be of mostly historical interest:
> it does the right thing in simple cases, and is implementation-dependent
> elsewhere.

I don't think that's right.  The whole point of boxes is to be
mutable; which means the correct treatment [1] thereof by equality
predicates is to compare by identity.  The only situation in which it
might be reasonable for an equality predicate to compare the contents
of boxes would be if they were both immutable.  In this case, however,
it may not be unreasonable to permit even eqv? and eq? to compare the
boxes' contents, on the grounds that an immutable box is a complete
no-op whose runtime representation may be worth eliding.  That sounds
too complicated to bring up, though.

[1] http://www.pipeline.com/~hbaker1/ObjectIdentity.html