On Friday, 24 May 2013 at 11:57:53 UTC, Don wrote:
On Friday, 24 May 2013 at 10:55:09 UTC, Artur Skawina wrote:
Hence, you are arguing for a change in behavior. And the
arguments for that
are extremely weak. The goal should be to allow const
initialization to happen
exactly once.
I agree. This is the crux of the argument.
Are you and I the the only ones who see that as a valuable
property of the language? I'm astonished that others are so
willing to sacrifice it.
If const variable initialization is allowed to happen exactly
once, then you'd prevent more complex initializations like the
following:
struct Test
{
immutable int[] lut;
immutable int cnt;
this(int mod)
{
lut.length = 999;
cnt = 0;
size_t last = 0;
foreach (i, ref e; lut)
{
if (i % mod == 0)
{
e = 42;
++cnt;
last = i;
}
}
lut.length = last + 1;
}
}