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

Juan Vuletich juan at jvuletich.org
Tue Mar 24 17:07:10 UTC 2009


Eliot Miranda wrote:
>
>
> On Mon, Mar 23, 2009 at 6:32 PM, Nicolas Cellier 
> <nicolas.cellier.aka.nice at gmail.com 
> <mailto:nicolas.cellier.aka.nice at gmail.com>> wrote:
>
>     1) #xor: should not take a block as argument.
>     Rationale:
>     - the block would ALWAYS have to be evaluated
>     - block arguments are either for repeated evaluation, or
>     condiitonal evaluation...
>     This is not the case here, so the need of a block argument vanishes...
>
>     2) #xor: argument should be a Boolean, but here no guard is made.
>
>     We could eventually add:
>        aBoolean isBoolean ifFalse; [self error: 'xor must take a
>     boolean as argument']
>
>     Or if we want to later extend to some other class:
>     True>>xor: aBoolean
>         ^aBoolean xorTrue
>     False>>xor: aBoolean
>         ^aBoolean xorFalse
>     True>>xorTrue
>         ^false
>     True>>xorFalse
>         ^self
>     False>>xorTrue
>         ^true
>     False>>xorFalse
>         ^self
>
>
> I think just
>
> True>>xor: aBoolean
>     ^aBoolean not
>
> False>>xor: aBoolean
>     ^aBoolean
>
> and then leave subsequent usage to catch possible type errors; e.g. 
> (false xor: #blah) ifTrue: ... will raise a mustBeBoolean error.
>

Oh, that's even better!

Thanks,
Juan Vuletich



More information about the Squeak-dev mailing list