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?
Generally it can't. Unfortunately our target languages are painfully difficult (and in the general case, nearly impossible) to optimize. :(
--
Dan
--------------------------------------it's like this-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk
