Charles O Nutter wrote: > > Closures are definitely made easier by having vars in multiple > IRubyObject[]...all they'd have to do is hold a reference to that frame. > If the method ends before the closure is called, it's no longer on the > Ruby frame stack...but it's still accessible in its final state to any > instantiated closures. The thought behind a single large stack was that > we could avoid reallocating that array every time to give some benefit > to blocks, but that benefit may not be enough to warrant additional > complexity (and may be incompatible with real closures). >
Just a quickie answer to your last point. I believe (without any great data for it right now) that to support real closures with the "single-array-model" we would have to jump through some _really_ strange hoops to get it working, or actually copy the references used to another place (and keep this updated for all closures in the same scope, etc). This is the reason in lisp (scheme) we can do this: (let ((a 0) (b 0)) (define inc () (set a (1+ a)) (set b (1- b))) (define dec () (set a (1+ a)) (set b (1- b)))) And the compiler have only two environment frames for this (the two parameter list environments are there too, but empty...), and the closures only need to keep a reference to the let-frame and everything just works, almost by magic. =) -- Ola Bini (http://ola-bini.blogspot.com) JvYAML, RbYAML, JRuby and Jatha contributor System Developer, Karolinska Institutet (http://www.ki.se) OLogix Consulting (http://www.ologix.com) "Yields falsehood when quined" yields falsehood when quined. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Jruby-devel mailing list Jruby-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jruby-devel