Chip Salzenberg writes: > According to Jonathan Scott Duff: > > Those classes that are "closed" can be opened at run-time and the > > user pays the penalty then when they try to modify the class [...] > > The optimization that can be reversed is not the true optimization.
While poetic and concise, I think that statement needs to be driven into the ground a bit more. Over on p6i, I think we're basically in agreement that the ability to undo optimizations is nothing we can count on. Unless there is a breakthrough in computer science any time soon, this while loop: sub one() { 1 }; sub go() { my $x = 0; while $x++ < one { # loop optimized away %main::{'&one'} = sub { 10 }; print "Boing!\n"; } } Is not something that can can be re-inserted when we find out one() has changed. While it's possible to make it so go() is unoptimized on the next call, that's not good enough. We expect changes to act instantly. But if you separate parsing and code-generation time, you can make optimizations earlier based on declarations later, which is just fine. It allows you to say: use PresumptuousModule << SomeClass >>; class SomeClass is extensible { }; Then even if the writer of PresumptuousModule thinks you'll be better off with the optimization, you can tell him otherwise. But you have to do it before the code is generated. Luke