Questions - RE: Dynamic scoping

Anthony Hannan ajh18 at
Wed Jan 29 01:10:32 UTC 2003

Avi Bryant <avi at> wrote:
> > 	2) If the answer to 1) is "yes", then couldn't the dynamic
> > 		scoping be accomplished by using accessor
> > 		methods instead of direct references to named objects?
> I think Anthony's code does largely that.  It doesn't do what I want,
> however, because there's no guarantee that the values will be restored if
> I reenter the same dynamic scope.

Do you mean:

	[self bar] in: (WorldHandler newWithWorld: [x])

	thisContext outer world

	^ worldBlock value

instead of:

	[self bar] in: (WorldHandler newWithWorld: x)

	thisContext outer world

	^ world

If so I understand what your getting at.  You want to read the same
variable not some copy.  I was thinking of something like the following:

	[self bar] in: {#world -> [x]. #user -> [y]}

	thisContext outer world

I originally rejected this because creating an array, associations, and
blocks each time was wasteful, especially for handlers with many
method/blocks.  But now I'm thinking the compiler can interpret this
specially, like it does with #ifTrue:, and create a single multi-method
block instead of many blocks and associations.  A multi-method block
would be like a block closure except it would respond to multiple
messages instead of just #value.  I believe Self has multi-method blocks
(I don't know what terminology they use).


More information about the Squeak-dev mailing list