Dynamic scoping
Anthony Hannan
ajh18 at cornell.edu
Thu Jan 30 23:38:59 UTC 2003
Attached is another version of my dynamic scoping and replaces the
previous one I sent out a couple of days ago. It now looks like:
foo
[self bar] on: #world do: [myWorld].
bar
thisContext outer world.
No more separate handler class and no multi-method handler. To handle
mutliple messages, you must nest mulitple on:do: blocks. I have found
that most of the time only one handler method is needed per protected
block. I have overloaded the on:do: method for efficiency with
exception handling and because of its like semantics (so its really not
overloading). "on: exceptionClass do: block" still works as before. In
either case a message is sent to the #outer of a context, which is the
closest #on:do: context sender wrapped in a ContextHandler. The message
is an arbitrary message like #world above, or it is #handleSignal: if an
exception is signaled. The contextHandler responds to #handleSignal:
(or the arbitrary message) by executing the do: block if the on: arg
handles the exception (or equals the message selector), otherwise it
forward the message to its outer #on:do: context. If no more #on:do:
contexts exist in the sender chain then a DefaultContextHandler is
created and sent the message. It calls #defaultAction on the exception
(or signals MessageNotUnderstood on the general message).
I will be including these changes with my closures-for-stock-vm package
coming soon.
Cheers,
Anthony
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ContextEnhCs-ajh.zip
Type: application/octet-stream
Size: 43376 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030130/f79374b3/ContextEnhCs-ajh.obj
More information about the Squeak-dev
mailing list
|