[ENH] ifNotEmptyCleans

Marcus Denker denker at iam.unibe.ch
Thu Sep 30 10:03:15 UTC 2004


Am 30.09.2004 um 10:04 schrieb ducasse at iam.unibe.ch:

> from preamble:
>
> "Change Set:		KCP
> Date:			30 September 2004
> Author:			stephane ducasse
>
> 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,
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.

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.


   Marcus




More information about the Squeak-dev mailing list