Dr.Ruud wrote:
Keith Ivey schreef:
Dr.Ruud:
Greg Matheson:
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

Of course, because that is what constant basically does for you.

Right, that's why Greg said it does very little -- meaning very little that the plain sub suggested by A. Pagaltzis doesn't do. Your response to him seemed to be suggesting that it was different. I guess I misinterpreted something.

--
Keith C. Ivey <[EMAIL PROTECTED]>
Washington, DC

Reply via email to