Wizard wrote:
> Johan Vromans wrote:
> > 'use constant FOO => "foo"' could add some magic to never let FOO
> > being redefined (not a bad coice for a constant).
> 
> I like this idea best (for now). Perhaps 'constant sub foo' or 'sub
> foo:constant'?

I wouldn't consider this an optimization. Perl is just doing what
you tell it -- the programmer is doing the optimization.

The idea of inserting "optimization ops" seems silly too. It would
be faster to just replace the definition of the sub whenever the
sub changes. Perl 6 subs are just as fast as ops.

The optimizer can't optimize what it doesn't know. You're
asking for some sort of "Quantum::SuperPosition::Optimizer" that
stores all optimization states at once.

The only way we're going to optimize Perl is by detecting dynamic
re-definitions. We also need to eliminate re-definitions of
compiled code. If all modules are loaded as source (not bytecode or
native code), then re-definition is fine. IMHO it is too difficult
to build a compiler that records its' optimization assumptions and
attempts to verify that the semantics of a re-definition are
consistent with the previous assumptions. (Hmm, maybe the optimizer
could record unoptimized definitions? Those would be safe to
replace. Dan?)

- Ken

Reply via email to