A possible suggestion for the Foreach loop

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Aug 21 10:45:03 PDT 2013


On 8/21/13 4:52 AM, John Colvin wrote:
> On Wednesday, 21 August 2013 at 02:46:06 UTC, Dylan Knutson wrote:
>> Hello,
>>
>> I'd like to open up discussion regarding allowing foreach loops which
>> iterate over a tuple of types to exist outside of function bodies.
>
> I would *LOVE* to have this.
>
> however, once we go down that route, it would be very tempting to allow
> a whole lot of other compile-time imperative style programming. Which
> would be awesome.

Not necessarily. We could allow "static foreach" as a functional 
construct that binds in turn a symbol to each element in a collection.

A static foreach in conjunction with string mixins would be great for 
simplifying code generation, e.g. "for each method in that class 
generate a method here".


Andrei




More information about the Digitalmars-d mailing list