DependentsArray size how does it work ?

Marcus Denker denker at iam.unibe.ch
Wed Feb 8 08:46:18 UTC 2006


On 08.02.2006, at 04:38, nicolas cellier wrote:

> 1) in squeak you can overwrite block arguments (storeIntoTemp: 0),  
> in not many
> Smalltalk you can do that i guess (not in VW anyway).
> In my opinion this is never something to do.

Yes, evil.

> 2) there must be a trick somewhere...

> On first pass, inject:into: should evaluate with count:0 dep:nil
> We will go through:
> 22 <73> pushConstant: nil
> 23 <94> jumpTo: 29
> ...
> 29 <7D> blockReturn
>
> Then the block should answer nil, shouldn't it ?
>
> Then, on second pass, shouldn't the block evaluate with: count:nil  
> dep:$0 ?
> Then, we would have count := nil+1 that would fail, that's what i  
> imagined...
>
> Not at all, all is going fine. Can anybody teach me ?
>

The do: is reimplemented, too. And inject:into: uses do:.
The do: now filters for nil, thus the count:0 dep:nil will not execute
anything.

And as dep can never be nil, the method could, I think,  look like this:

size
	^self inject: 0 into: [ :count :dep |  count + 1 ]


     Marcus




More information about the Squeak-dev mailing list