in reply to What is the difference between the constant construct in Perl and the Readonly construct in Perl?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is the difference between the constant construct in Perl and the Readonly construct in Perl?
by rodion (Chaplain) on Jul 06, 2006 at 15:19 UTC | |
by BrowserUk (Patriarch) on Jul 06, 2006 at 19:12 UTC | |
|
Re^2: What is the difference between the constant construct in Perl and the Readonly construct in Perl?
by Anonymous Monk on Jul 06, 2006 at 02:55 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |