in reply to Re: 'constant' vs array (Ignore bad benchmarks: [mod://constant] arrays are (a little) faster!)
in thread 'constant' vs array

The problem is such a reference is constant, but its members are not:
ARRAY->[0] = 'not so constant'; print ARRAY->[0];
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re^2: 'constant' vs array (Ignore bad benchmarks: [mod://constant] arrays are (a little) faster!)
  • Download Code

Replies are listed 'Best First'.
Re^3: 'constant' vs array (Ignore bad benchmarks: [mod://constant] arrays are (a little) faster!)
by BrowserUk (Patriarch) on Jul 02, 2013 at 15:59 UTC
    but its members are not:

    I guess if you think you might 'accidentally' modify something you've defined as a constant that might be a problem.

    But the primary uses of constant are:

    1. Giving literals meaningful (symbolic) names.
    2. Making it obvious to yourself and other programmers that this thing is a program defined literal by the use of a CLEARLY_DIFFERENT_SYNTAX.

      Even $UPPER_CASE doesn't achieve that (as well).

      Using variable name syntax for things that are not variable makes no sense.

    3. Availing yourself of the optimisations that come from informing the compiler that this entity is not going to change.

      The oxymoronic read-only variables can not do this.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.