[Issue 2411] Reference Tuple Foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 1 13:44:50 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=2411



--- Comment #6 from David Simcha <dsimcha at yahoo.com> 2012-01-01 13:44:46 PST ---
(In reply to comment #5)
> My patch requires explicit 'ref'.
> 
> void main() {
>     S s;
> //  foreach(    element; s.tupleof)  // doesn't work
>     foreach(ref element; s.tupleof)  // OK
>         element = 2;
>     assert(s.foo == 2);
>
(In reply to comment #5)
> My patch requires explicit 'ref'.
> 
> void main() {
>     S s;
> //  foreach(    element; s.tupleof)  // doesn't work
>     foreach(ref element; s.tupleof)  // OK
>         element = 2;
>     assert(s.foo == 2);
> }

It seems to me like the only logical way to do this is to require explicit ref.
 The semantics should be the same as foreach over ranges.  Nice work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list