www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21913] New: [Statements] foreach (index,value;range); sugar

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

          Issue ID: 21913
           Summary: [Statements] foreach (index,value;range); sugar is
                    undocumented and narrow
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: crazymonkyyy gmail.com

if you attempt to return a Voldemort type that defines value or index as a
function, or stores it in a struct when you call for each you get an error like

auto front{
  struct dataaccess{
    int index;
    T value;
  }
  return dataacess(start,data[start]);
}

Error: cannot infer argument types, expected 1 argument, not 2
It seems to require exactly an std.tuple, and the spec should say as much or clarify how it works --
May 10