www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5403] New: foreach requires front to be a function in a range

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5403

           Summary: foreach requires front to be a function in a range
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: schveiguy yahoo.com



07:25:54 PST ---
This is a valid range:

import std.range;

struct S
{
    int front;
    bool empty;
    void popFront() {empty = true;}
}

static assert(isInputRange!S);  // compiles

But this fails:

void main()
{
    S s;
    foreach(int i; s) { }
}

fails with the following error:

Error: no property 'opApply' for type 'S'
Error: opApply() function for S must return an int

Change front to:

 property int front() {return 0;}

and it compiles.  Clearly empty is not required to be a function, and there is
no mention of any function requirements in the spec, it's just stated that they
must be properties.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 03 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5403


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |2korden gmail.com



*** Issue 3295 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5403


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         OS/Version|Linux                       |All



https://github.com/D-Programming-Language/dmd/pull/203

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 03 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5403




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/85511f3cca367fa0b1d49a4748f3f047ff138425
Fix Issue 5403 - foreach requires front to be a function in a range
Allow using any reasonable symbol as front/back/empty.
Remove references to the old range interface (head/toe/next/retreat)

https://github.com/D-Programming-Language/dmd/commit/b33914398d44535296d9a80e50a3c3eeba70a0a0


Issue 5403 - foreach requires front to be a function in a range

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5403


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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