[Issue 9817] Syntax change for front tuple expansion in foreach

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 13 14:33:26 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=9817

Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |schveiguy at yahoo.com
         Resolution|---                         |WONTFIX

--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> ---
This is a feature of foreach on ranges, not arrays. Arrays are arrays first,
and ranges second.

It's the reason foreach(c; "string") doesn't iterate dchars by default, and the
reason foreach(dchar d; "string") works, but foreach(dchar d; someCharRange)
does not.

I think you are talking about two different things here. While I agree that
foreach being able to use tuples to unpack in the syntax you propose would be
nice, I don't think it hurts to omit the parentheses.

Unpacking tuples syntax can exist alongside the existing mechanism. In any
case, the mechanism is too far ingrained into the language to be simply
deprecated. We can revisit at a later date if/when tuple unpacking becomes
possible.

--


More information about the Digitalmars-d-bugs mailing list