[squeak-dev] did ifEmpty:ifNotEmpty: change?

Levente Uzonyi leves at elte.hu
Fri Mar 12 22:14:03 UTC 2010


On Fri, 12 Mar 2010, Chris Muller wrote:

> I really like the new printing of CompiledMethods and the detail of
> the byteCodes compared to 3.9.  Certainly a big step in helping me
> understand them.  Now I'm going to have to review all of my code,
> because I think I have not been paying attention to this sort of
> optimization.
>
> This would probably make a good Lint check..

I'm pretty sure there's a check in Lint for this.


Levente

>
> On Fri, Mar 12, 2010 at 3:09 PM, Nicolas Cellier
> <nicolas.cellier.aka.nice at gmail.com> wrote:
>> 2010/3/12 Chris Muller <ma.chris.m at gmail.com>:
>>> I know the semantics of ifEmpty: and ifNotEmpty: changed in the trunk
>>> image last year, to answer the receiver instead of nil in the other
>>> case.
>>>
>>> However, I also noticed ifEmpty:ifNotEmpty: changed but I'm not seeing
>>> any semantic difference.  Is there some subtlety I'm missing by the
>>> new:
>>>
>>> ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock
>>>        "Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise"
>>>        " If the notEmptyBlock has an argument, eval with the receiver as its argument"
>>>
>>>        self isEmpty ifTrue: [ ^emptyBlock value ].
>>>        ^notEmptyBlock valueWithPossibleArgument: self
>>>
>>> vs. old:
>>>
>>> ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock
>>>        "Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise"
>>>        " If the notEmptyBlock has an argument, eval with the receiver as its argument"
>>>
>>>        ^ self isEmpty ifTrue: emptyBlock ifFalse: [notEmptyBlock
>>> valueWithPossibleArgument: self]
>>>
>>> ?
>>>
>>> Thanks,
>>>  Chris
>>>
>>
>> Well, just take a look to bytecodes generated by each variant.
>> Only an optimization I think.
>>
>> Nicolas
>>
>>
>
>


More information about the Squeak-dev mailing list