Re: static foreach direct use of variables

2019-01-01 Thread Michelle Long via Digitalmars-d-learn
On Tuesday, 1 January 2019 at 21:34:08 UTC, Paul Backus wrote: On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote: auto foo(S s) { static foreach(k, p; [s, this]) for(int i = 0; i < p.length; i++) ... } The idea is to provide single

Re: static foreach direct use of variables

2019-01-01 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote: auto foo(S s) { static foreach(k, p; [s, this]) for(int i = 0; i < p.length; i++) ... } The idea is to provide single for loop structure for each of the variables(in this case s and

Re: static foreach direct use of variables

2019-01-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote: auto foo(S s) { static foreach(k, p; [s, this]) for(int i = 0; i < p.length; i++) ... } try static foreach(...) {{ stuff }} The double {{ and double }} are intentional.

static foreach direct use of variables

2019-01-01 Thread Michelle Long via Digitalmars-d-learn
auto foo(S s) { static foreach(k, p; [s, this]) for(int i = 0; i < p.length; i++) ... } The idea is to provide single for loop structure for each of the variables(in this case s and this). The is to avoid string mixins which are pathetic for