Semantics of mixed CT and RT statements
Timoses
timosesu at gmail.com
Mon Dec 24 01:08:57 UTC 2018
On Sunday, 23 December 2018 at 02:58:30 UTC, Neia Neutuladh wrote:
>
> 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.
> The sticky bit is that a runtime check needs both paths to
> typecheck, so if you're mixing metaprogramming with runtime
> logic, some cases might be weird.
Do you have an example? I'm not quite sure I get what you mean.
>
> I've never needed to do that.
More information about the Digitalmars-d
mailing list