Semantics of mixed CT and RT statements
divide at by.zero
Mon Dec 24 10:16:59 UTC 2018
On Monday, 24 December 2018 at 01:08:57 UTC, Timoses wrote:
> On Sunday, 23 December 2018 at 02:58:30 UTC, Neia Neutuladh
>> An optimizer can very easily optimize this:
>> // T is SomeType
>> if (is(T == SomeType) || b) doStuff;
>> to remove the if statement. So from that perspective, no need
>> to worry about it.
> Good point. I guess that eliminates the need for something like
> "static if (T) || if (b)".
> However, going along that line, why does D even have "static
> if"? We could simply use "if" everywhere and let the compiler
> take care of it. Perhaps it's more a question of expressiveness.
static if gives you a guarantee it'll be evaluated at run time
and the dead code branch pruned away. Not sure if the scoping
also has different semantics vs a regular if.
More information about the Digitalmars-d