Is there a need for final variables now that we have immutable and const in D2 ?
This program does not compile:
import std.stdio;
int main(char[][] args)
{
final int a = 4;
a = 8;
writefln("%s", a);
return 0;
}
But the following program does run:
import std.stdio;
int main(char[][] args)
{
final int a = 4;
final int* p = &a;
*p = 8;
writefln("%s", a);
return 0;
}
and prints 8.
So final for variables seems weaker than C const.
Another problem is that final looks like Java :)
