New feature proposal: "initialization scope"
TommiT
tommitissari at hotmail.com
Thu May 16 02:32:39 PDT 2013
On Thursday, 16 May 2013 at 08:31:27 UTC, Jonathan M Davis wrote:
> Normally, there's no performance hit to doing any of this, but
> it is true that
> that's a potential issue in your example, because it's a static
> variable. [..]
I assume you mean the variable is statically allocated. Which, I
assume, means that there's an actual memory copy involved when
such variable is cast to immutable.
Here's some more of the logic behind my suggestion:
Any hoops, that the programmer has to go through in order to make
his function-local variable a const/immutable, discourages him
from making the variable const/immutable. To me, it seems that
the path of least resistance for the programmer is simply not
make it const/immutable. By discouraging const-correctness we
encourage writing bugs.
More information about the Digitalmars-d
mailing list