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

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.
  • Comment on Re^3: 'constant' vs array (Ignore bad benchmarks: [mod://constant] arrays are (a little) faster!)
  • Select or Download Code