In what seems to have become an autumn tradition in the Parrot community, I am about to make my third annual attempt to implement Parrot support for what Common Lisp calls "special variable binding." Most of the rest of the world calls it "dynamic binding" or "dynamic scoping" [1]; after last fall's email discussion [2], I am hoping that "dynamic variable scoping" will capture the, ah, scope of this particular project in a way that is satisfactory to everyone.
In the aforementioned thread [2], we seem to have reached a number of conclusions about what "dynamic variable scoping" should mean. I have summarized these below, to be sure we're all on the same page. If I don't hear objections in the next week, I will start updating the proposal. FWIW, I am (re-)starting this project a few weeks earlier than I did last year, so I am supremely confident that I will have the third implementation ready by Christmas. At which time, if tradition holds, the Powers That Be will veto it. ;-) -- Bob Rogers http://rgrjr.dyndns.org/ Project summary: 1. The dynamic variable scoping mechanism will address only global variables, not registers or slots in aggreggates (e.g. arrays). 2. This mechanism will do binding, rather than assignment, where "binding" is defined thus: "A binding replaces the PMC stored in the namespace or lexical pad with another PMC [3]." 3. It may be possible to use dynamic variable scoping to implement Perl 5 "local" and Perl 6 "temporization" in the case of binding of global variables. However, full implementation of these features would have to go far beyond this, so support for "temporization" is not a design goal. 4. Dynamic variable binding state must be stored on the dynamic environment stack, so that dynamic values are available to called subs, and can be captured and restored by continuations. This in turn requires new instructions to manipulate dynamic bindings on the dynamic environment stack. 5. Dynamic variable bindings must be visible only within that thread. Besides being useful in its own right, this makes it possible to use thread-scoped dynamic variables to implement thread-scoped dynamic control structures (e.g. coroutines, Lisp CATCH/THROW). 6. The implementation should not multiply PMC classes beyond necessity. References: [1] http://en.wikipedia.org/wiki/Dynamic_variable_scoping#Dynamic_scoping [2] http://groups.google.com/group/perl.perl6.internals/browse_thread/thread/1fd0d3b432c2e425/fb9071f9697552a3?hl=en&lnk=st [3] Quoting Allison's message of 7-Dec-2006 from thread [2].