Definitive list of storage classes

MoonlightSentinel moonlightsentinel at disroot.org
Sat Jan 30 01:46:24 UTC 2021


On Friday, 29 January 2021 at 21:32:19 UTC, kdevel wrote:
> Unfortunately I could not find a reasonable recap on this 
> issue. In [1]

The problem is that dmd treats const/immutable variables kinda 
like enums when they have an initializer. The final AST never 
accesses x, y but uses their initializers instead:

immutable immutable(int) x = 2;
const const(int) y = 2;
int z = 2;
void main()
{
	writeln(2);
	writeln(2);
	writeln(z);
	return 0;
}


More information about the Digitalmars-d mailing list