Questions - RE: Dynamic scoping
avi at beta4.com
Wed Jan 29 20:37:40 UTC 2003
On Wed, 29 Jan 2003, Stephen Pair wrote:
> Avi Bryant wrote:
> > Well... almost. If I were going to build my idea of a
> > dynamic scope mechanism on top of yours, it would be more like this:
> > foo
> > |x|
> > ...
> > [self bar] in: (WorldHandler newWithGet: [x] set: [:v | x := v])
> > WorldHandler world
> > ^ getBlock value
> > WorldHandler world: aWorld
> > getBlock value: aWorld
> > But actually the crucial thing here (again, for me) is that x
> > is a temp, not an inst var, and so that binding will get
> > copied when the stack does.
> Yikes! Anthony's abuse of #doesNotUnderstand: seems mild in comparison
> to this abuse of blocks and stack copying! An excessive use of blocks
> can obfuscate code just as much (and perhaps more) than abusing
I wasn't very clear - this is certainly ugly, and it's not how I would
choose to do things from scratch. It's simply the twisted way in which I
would implement my desired semantics on top of Anthony's implementation,
if Anthony's implementation were all I had to work with.
> I would focus on keeping Continuation as simple as possible (so that its
> semantics are relatively easy to grok), yet make it robust enough to
> satisfy some common needs (like not having to abuse blocks in this way
> and doing the right thing wrt to dynamic scoping).
But that's exactly the point - ideally Continuation should do nothing more
than copy the stack. No special cases. Then its behavior is extremely
predictable. And actually, that's pretty much how it works now, and it
works quite well. All I'm doing is expressing a preference that whatever
dynamic scoping we do, be integrated with the stack naturally enough that
Continuation can continue not to need special cases. But since we don't
seem in any danger of immediately adopting a dynamic scoping mechanism,
it's not something I feel a need to argue about much more.
More information about the Squeak-dev