On Thu, Feb 02, 2006 at 12:51:36PM +0100, Leopold Toetsch wrote: : Another idea: : : We keep the call frame of subs with statics (or Perl6 INIT and FIRST : blocks) after returning from the sub. Additionally, we can set a new : entrypoint for the sub after running the INIT code (or static : initializer). The entrypoint would be reset for cloning closures to : achieve perl6 FIRST block semantics.
Uh, maybe I'm pointing out something that's already blindingly obvious to everyone else, but for "state" variables cloned closures can't use the same static storage location. (Or is that what you're meaning already by "keep the call frame"?) : The draw backs are increased memory usage and it doesn't work together : with recursive subroutines easily, albeit I don't know, if recursive : subs with statics are really meaningful. Unlike the situation with clones, a "state" variable *is* shared between recursive invocations. As for whether that's meaningful, I don't know either. But you could, say, temporize such a variable just like a global, and that might make some kind of sense. Anyway, the P6 model of "state" is more like a persistent lexical than like C's static. (Though of course Parrot will probably want C's static semantics for various other languages...) Anyway, I thought I'd clarify a bit--we just don't want people confusing "state" with "static", given the similarity of the names. Larry