Bill~

On Tue, 30 Nov 2004 22:12:30 -0800, Bill Coffman <[EMAIL PROTECTED]> wrote:
> On Tue, 30 Nov 2004 14:45:39 -0500, Dan Sugalski <[EMAIL PROTECTED]> wrote:
> 
> 
> > At 11:20 AM -0800 11/30/04, Jeff Clites wrote:
> > >% cat continuation6.ruby
> > >def strange
> > >     callcc {|continuation| $saved = continuation}
> > >end
> > >
> > >def outer
> > >     a = 0
> > >     strange()
> > >     a = a + 1
> > >     print "a = ", a, "\n"
> > >end
> >
> > Through the joys of reference types, a will continue to increase
> > forevermore, assuming the compiler hasn't incorrectly put a in an int
> > register. (Which'd be wrong)
> 
> I can see that there is true magic in the power of using references in
> this way.  Nonetheless, how can the compiler figure out that it can't
> use an integer here?  The compiler should use integers when it can,
> but it sounds like you are saying that when a variable crosses a sub
> call (which might invoke a continuation) it will then have to be a PMC
> or String to do the right thing.

This has come up before.  It turns out that the compiler will likely
be able to make very few optimizations of this sort on its own. 
However, user code rarely needs this kind of optimization.  Library
code is what should really get it, and the library author can provide
hint/directives to the compiler for cases like this.  If you took a
continuation inside a callback from a library routine and then invoked
it, I don't think that you would have any reasonable guess what the
library routine would do, so either behavior would seem reasonable.

Matt
-- 
"Computer Science is merely the post-Turing Decline of Formal Systems Theory."
-???

Reply via email to