On Sun, Mar 04, 2007 at 11:27:44AM -0500, Keith Ivey wrote:
> Dr.Ruud wrote:
> >Greg Matheson schreef:
> >>A. Pagaltzis:
> >
> >>>Write the same thing without syntactic sugar from constant.pm.
> >>>    sub C1     () { 'C1' }
> >>Mmh. I see constant.pm does very little.
> >
> >Well, it nicely sets things up for the compiler to optimize. 
> >
> >perl -MO=Deparse -e 'use constant PI => 3.1415; print PI'
> >use constant ('PI', 3.1415);
> >print 3.1415;
> >-e syntax OK
> 
> Greg's version gets optimized as well:
> 
> perl -MO=Deparse -e'sub PI () {3.1415} print PI'
> sub PI () { 3.1415 }
> print 3.1415;
> -e syntax OK

As of 5.10, use constant will use less memory than Greg's version.
I'm loathe to make the same changes for 5.8.9, as the implementation
confuses some modules that inspect the symbol table. The necessary
infrastructure will be in 5.8.9 though.

Nicholas Clark

Reply via email to