const vs immutable for local variables

spir denis.spir at gmail.com
Thu Nov 18 03:27:25 PST 2010


On Thu, 18 Nov 2010 08:50:58 +0000
Russel Winder <russel at russel.org.uk> wrote:

> I am a fan of single assignment so I put immutable on all my variables
> except for loop control variables and accumulators.  I haven't yet seen
> a need for const.

For me, this is the default as well, meaning locals are constant. I would love it to be the default for the language (or an option to set it so), so that one would declare local _variables_. Which is never needed, and even shows bad practice, except for symbols assignmed in loops, as you say.
This extends to _value_ parameters, which are just locals as well (in other words, "in" is the default for non-referenced parameters).

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d-learn mailing list