Is old style compile-time foreach redundant?
Timon Gehr
timon.gehr at gmx.ch
Tue Jan 9 23:18:46 UTC 2018
On 09.01.2018 22:04, H. S. Teoh wrote:
> if (0 == 3) {}
> // all subsequent iterations deleted
>
> because the static break is unconditionally compiled (it has nothing to
> do with the runtime branch). You'd have to use static if to make it
> conditionally-compiled and thus not instantly aborting the loop.
>
> Such semantics would be logically consistent, but unfortunately rather
> counterintuitive at first glance.
I think "if (0 == 3) { static break; }" should be a compile-time error.
More information about the Digitalmars-d-learn
mailing list