std.format and uninitialized elements in CTFE

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Dec 6 13:16:18 UTC 2019


On Friday, 6 December 2019 at 12:47:14 UTC, berni44 wrote:
> On Friday, 6 December 2019 at 06:49:41 UTC, berni44 wrote:
>> int a = void;
>>
>> static if (!__traits(compiles, a?a:a))
>>
>> But I'm not sure if ?: can be applied to all thinkable types.
>
> Even that doesn't work (don't know, why I got this morning the 
> impression, that it does).
>
>
> Is the following a bug in __traits?

Probably not, because foo(…) could have been separately compiled 
in a different file unit?

However, I think this and many other cases show that Walter is on 
the right track by using flow-analysis, but that D as a language 
would be better served by embracing Flow-typing whole-heartedly 
and take flow-analysis to the next level rather than doing it 
here-and-there.

E.g. tracking of 
constness/immutability/nullability/initialization/aliasing etc 
can be done in new and intersting way if D adds flowtyping in a 
wholesome manner.

It would probably require a new IR and perhaps break too much, so 
you would end up with D3m but it would be great from a 
metaprogramming perspective.



More information about the Digitalmars-d mailing list