[OT] static foreach

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 4 13:23:12 PST 2017


On 04.01.2017 17:03, Stefan Koch wrote:
> On Wednesday, 4 January 2017 at 15:56:13 UTC, Timon Gehr wrote:
>
>> [1] Both static if and static foreach (once it lands) need the same
>> kind of scoping rules.
>
> Please do contact me if you are working on static foreach,

Not currently. I might implement it in 
https://github.com/tgehr/d-compiler soon though. I'll let you know.

> there are dmd and implementation specific issues to be taken into account.

What kind of issues? The compiler implementation shouldn't matter for 
the definition of the static foreach behaviour.

Generation of the sequence of values assigned to the loop variables 
should be exactly like runtime foreach, scoping of the loop variables 
should be local. For scoping of the declarations within the static 
foreach body, there are multiple possibilities. (The most obvious thing 
is to just insert them into the outer scope, but then we need some other 
improvements in order to avoid having to string mixin each and every 
declaration in the body.)

There are some questions about which dependency structures should be 
allowed for the loop aggregate and the declarations in the loop body, 
but I think this is mostly orthogonal to static foreach itself.


More information about the Digitalmars-d mailing list