[squeak-dev] [bug] xor: is this an old bug or what?

Eliot Miranda eliot.miranda at gmail.com
Tue Mar 24 22:01:45 UTC 2009


On Tue, Mar 24, 2009 at 1:36 PM, Randal L. Schwartz
<merlyn at stonehenge.com>wrote:

> >>>>> "Eliot" == Eliot Miranda <eliot.miranda at gmail.com> writes:
>
> Eliot> I think just
>
> True> xor: aBoolean
> Eliot>     ^aBoolean not
>
> False> xor: aBoolean
> Eliot>     ^aBoolean
>
> Eliot> and then leave subsequent usage to catch possible type errors; e.g.
> (false
> Eliot> xor: #blah) ifTrue: ... will raise a mustBeBoolean error.
>
> What I don't like about this is that the right operand doesn't get a chance
> to
> "boolify" itself, or define its own xor logic.  The double-dispatch
> versions
> were a lot better at that.




If you want to do that you could implement it as

False> xor: aBoolean
    ^aBoolean not not

but I'd argue that isn't necessary.  The old code didn't type check and
we've lived with it for a loooong time.

But in any case, the not is a form of double-dispatch.  It just points out
that one can use not instead of xorTrue and is more comprehensible because
"not" is familiar.



>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.vox.com/ for Smalltalk and Seaside
> discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090324/fd3aecb9/attachment.htm


More information about the Squeak-dev mailing list