A Perspective on D from game industry
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 17 07:42:38 PDT 2014
On 06/17/2014 04:00 PM, John Colvin wrote:
>
> I though the primary use of static foreach was to force the
> compiler to attempt compile-time iteration even for
> non-TemplateArgList arguments like arrays known at compile-time
>
> e.g.
>
> static foreach(el; [1,2,3,4])
> {
> pragma(msg, el);
> }
>
> or
>
> static foreach(el; 5 .. 8)
> {
> pragma(msg, el);
> }
No, that's a distinct use and IMO shouldn't be called static foreach (it
would be inconsistent with static if in how scopes are handled.)
In any case, it is a quite boring use case as well, one can write a
template that converts a range into such a list and then plain foreach
will work.
More information about the Digitalmars-d
mailing list