laziness, impatience, and hubris | |
PerlMonks |
Re: What is the difference between the constant construct in Perl and the Readonly construct in Perl?by BrowserUk (Patriarch) |
on Jul 06, 2006 at 02:07 UTC ( [id://559467]=note: print w/replies, xml ) | Need Help?? |
Besides all the optimisation features of constant so carefully omitted by the Readonly docs (as noted by diotalevi++), another of things I especially like about use constant SYMBOL => 123;, is that my constants don't look like variables. All the hyperbole about Readonly exported variables being immutable makes me think of nothing more than the old saying about constants that aren't and variables that won't. I cannot imagine why anyone would want their constants to look like variables? The minor inconvenience of using (s)printf in order to embed the values of constants into strings is actually a plus. If I define pi in my program, I'm gonna define it to the full accuracy of whatever math I'm using supports. For standard floats that's use constant PI => 3.1415926535897931; in order to use the best accuracy in my calculations. But if I'm going to display pi, I'm probably going to settle for showing 3 or 4 decimal places. (s)printf are the tool for this, so it works out great. Another ill-thought through solution to a non-problem foisted on the world under the title of a best practice. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|