Which language futures make D overcompicated?

Andrea Fontana nospam at example.com
Fri Feb 9 15:48:42 UTC 2018


On Friday, 9 February 2018 at 15:35:38 UTC, Mike Parker wrote:
> On Friday, 9 February 2018 at 15:27:18 UTC, Andrea Fontana 
> wrote:
>
>>> If you need to take the address of a constant, use immutable 
>>> or const (doesn't really matter, but I prefer immutable). If 
>>> you don't need the address, use enum.
>>
>> Why not static immutable?
>
> For global scope? static has no effect there as far as I know. 
> Looking at the ASM output on run.dlang.io, I see no difference 
> between the two:
>
> static immutable foo = 10;
> immutable bar = 20;
>
> LAT	group	
> ;File = onlineapp.d
> 	public	immutable(int) onlineapp.foo
> 	public	immutable(int) onlineapp.bar
>
> ...
>                 mov	EDI,0Ah
> 		call	  @safe void 
> std.stdio.writeln!(immutable(int)).writeln(immutable(int))@PLT32
> 		mov	EDI,014h
> 		call	  @safe void 
> std.stdio.writeln!(immutable(int)).writeln(immutable(int))@PLT32

If I'm right on classes/structs static immutable != immutable. So 
if you need to replace enum in those cases too, static immutable 
works fine everywhere. Right?




More information about the Digitalmars-d mailing list