From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> > Prototypes can be avoided by prepending a & to the function call -- > that's just the way it goes. That way, you can say: > > $avg = &average([<FILE>]); > > if you really wanted to. I don't condone this, personally.
> Now, what are 'constants' in Perl? Well, the 'use constant' pragma > basically creates a function with an empty prototype. What does that > mean for Perl? Well, Perl treats such functions specially -- if it > sees a function with an empty prototype (that is not the same as NO > prototype), then it examines the function body to see if it returns a > constant (known) value. If it does, then it replaces all instances of > that function call with the literal return value. > > &FOO is NOT a bareword. Moreso, &FOO supercedes the empty prototype. Actualy it's even a little bit crazier. It only supercedes the prototype if followed by (...). If you only have &FOO it calls the function with the current contents of @_. (Something I would be able to tell you all the time, but kind of forget about it when working with the constants :-( If anyone's interested here http://Jenda.Krynicky.cz/to_at_or_not_to_at.txt is a script that shows what happens. > Thus, accessing constants via &CONST is slower than, and not the same > process as, accessing it via CONST (or +CONST or CONST()). I benchmarked it and it IS a measurable difference. Thanks Jeff & Randal Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]