[ENH] ifNotEmptyCleans
stéphane ducasse
ducasse at iam.unibe.ch
Thu Sep 30 10:41:12 UTC 2004
>> transform
>> Collection>>ifNotEmpty: aBlock
>>
>> ^ self isEmpty
>> ifFalse: [aBlock valueWithPossibleArgs: {self}]
>>
>> into
>>
>> ifNotEmpty: aBlock
>>
>> ^ self isEmpty
>> ifFalse: [aBlock value]
>>
>> which corresponds to the method comment
>> Evaluate the block unless I'm empty"
>> !
>> <ifNotEmptyCleans.cs.gz>
>>
>
> No good idea: we need to support *both*
>
> aCollection ifNotEmpty: [:arg | arg doSomething]
>
> and
>
> aCollection ifNotEmpty: [ self doSomething].
>
>
> This is really important, as VW and RB define ifNotEmpty: to require
> a block,
you mean anargument?
> but squeak's implementation used to not require one. So we need the
> implementation
> that allows both, or we need to fix a lot of senders.
For me I do not understand what it means to require an argument, in
this case this is not
ifNotEmpty: [do that]
but ifNotEmpty: [do that with self]
and the message does not tell that at all
and why we have that for ifNotEmpty and not for ifTrue: and isNil:
Really I do not understand and as a user of the interface I do not get
that at all.
IF people need that then why don't they write
ifNotEmptyDoWithMe: []
> I really like the valueWithPossibleArgs: thingy: It does a
> double-dispatch on the number of arguments
> of the block, and just does the right thing. We really should keep it.
But not like that. Sorry this is really bad
>
>
> Marcus
>
>
More information about the Squeak-dev
mailing list
|