CT foreaches
monkyyy
crazymonkyyy at gmail.com
Fri Aug 1 15:47:47 UTC 2025
On Friday, 1 August 2025 at 15:15:35 UTC, Nick Treleaven wrote:
>
> Up to here is all as expected, right?
No, `foreach(alias` is functionally undocumented (dip 1010 is not
exactly common reading material for current year, and if you did
read it, it would have errors or misunderstanding for what
eventually happened) and extremely rare
>
>> pragma(msg,"---");
>> foreach(enum i;0..3){// ERROR ISNT CT. ISNT AN ENUM
>> pragma(msg, i.stringof);
>> //foo!i; //doesnt compile
>
> You're using runtime foreach here. It's only expanded at
> compile-time when the aggregate is a sequence - as the spec
> says.
>
`foreach(enum i;0..3){` is directly from the dip 1010 its unclear
from the responce if it was accepted or rejected
>> b) enum or alias of aliasSeq, whoever made thought there be an
>> upgrade to fully generalize the syntax
>
> Not sure what you mean for (b).
dip 1010 was optimistic about near term upgrades to static
foreach; static break and continue
---
> The confusing thing is that enum there is silently ignored. I
> think we could add an error for that.
That would be a breaking change now, most code swapped from
runtime to ct should continue working tho, better to just
implement it
More information about the Digitalmars-d
mailing list