[squeak-dev] [bug] xor: is this an old bug or what?
Eliot Miranda
eliot.miranda at gmail.com
Tue Mar 24 16:59:14 UTC 2009
On Mon, Mar 23, 2009 at 6:32 PM, Nicolas Cellier <
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.
MySymbolicBooleanClass>>xorTrue
> ^SymbolicXorOperation with: self with: true
>
> I'm not sure whether we need to protect or not...
> I tend to avoid over-protecting code. As long as a debugger opens, I claim
> protecting is void...
+1
>
> But here, I don't like a false program proceeding without a Notifier....
>
> Nicolas
>
> 2009/3/24 Keith Hodges <keith_hodges at yahoo.co.uk>
>
>> true xor: [ true ] => true
>>
>> discuss
>>
>> Keith
>>
>>
>>
>>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090324/2eb3d8cb/attachment.htm
More information about the Squeak-dev
mailing list
|