Block returns out of scope?

Tim Rowledge rowledge at
Tue Aug 25 13:49:58 UTC 1998

On Wed 26 Aug, Maurice Rabb wrote:
> MessageTally>>printOn: aStream
>         | aSelector className |
>         aSelector _ class
>             selectorAtMethod: method
>             setClass: [:aClass]. <------------------- NOTE#1
>         className _ aClass name contractTo: 30.

> Is this a this good or bad style?  How is it even possible given the
> scoping once the recusive method has returned?
It's not only poor style, it shouldn't compile!

It only works because the compiler adds 'aClass' to the method's list of
temps when it discovers it in the block, and then doesn't rescind its scope
correctly and the doens't take notice of it later. I did some hacking to
make block temps work a while ago that 'fixed' this, I'll try to remember
to extract the relevant bits tomorrow.

What should be written there is
........setClass:[:aClass| theClass := aClass].
and 'the Class' would need be a proper method temp.


Useful random insult:- Barney's his hero.
Tim Rowledge:  rowledge at (w)  +1 (650) 842-6110 (w)
 tim at (h)  <>

More information about the Squeak-dev mailing list