in reply to What is the difference between the constant construct in Perl and the Readonly construct in Perl?
The author of Readonly has inspired my ire by neglecting to mention the positive reasons to use constant. I wrote a note at AnnoCPAN and I'm reproducing it for you here as well.
You didn't mention that the constant pragma allows the value to get inlined into the optree. You also didn't mention that when constants are used in conditionals, perl is able to optimize away the non-executable branches.
Further you didn't mention that constant.pm tracks perl's preferred implementation for constants. Prior to 5.9.4 constants were implemented as functions like sub FOO () { 1 }. After that perl does something a little bit different which allows for a smaller memory footprint.
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is the difference between the constant construct in Perl and the Readonly construct in Perl?
by tinita (Parson) on Jul 06, 2006 at 08:35 UTC | |
by Argel (Prior) on Jul 07, 2006 at 19:30 UTC | |
|
Re^2: What is the difference between the constant construct in Perl and the Readonly construct in Perl?
by esskar (Deacon) on Jul 07, 2006 at 14:57 UTC | |
by Happy-the-monk (Canon) on Jul 07, 2006 at 19:29 UTC | |
by revdiablo (Prior) on Jul 10, 2006 at 21:57 UTC |