www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3123] New: std.algorithm.zip fails on 'lazy' ranges

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

           Summary: std.algorithm.zip fails on 'lazy' ranges
           Product: D
           Version: 2.030
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: k-foley onu.edu


By 'lazy' range, I mean what iota, map, take, etc. return.  I don't know the
correct term for these types of ranges.
----

auto a = [1, 2, 3, 4, 5][];
auto b = [2, 4, 6, 8, 10][];

// this compiles and works fine
foreach ( e; zip(a, b) ) writeln( "(", e.at!0, ", ", e.at!1, ")" );

// the following do not
foreach ( e; zip(a, iota(0, 6)) ) writeln( "(", e.at!0, ", ", e.at!1, ")" );

foreach ( e; zip(a, take(5, repeat(42))) ) writeln( "(", e.at!0, ", ", e.at!1,
")" );

foreach ( e; zip(a, map!(`a*a`)(a)) ) writeln( "(", e.at!0, ", ", e.at!1, ")"
);

----
Here is the compilation error:

C:\d\dmd.2.030\dmd\windows\bin\..\..\src\phobos\std\range.d(1734): Error:
cannot
 implicitly convert expression (&this.ranges._field_field_1.front) of type int
d
elegate() to int*

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


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha yahoo.com



The problem looks to be a question of whether range.front is an lvalue or not. 
When range.front is an lvalue, DMD interprets &range.front as taking the
address of the front element of the range.  When range.front is not an lvalue,
DMD interprets &range.front as taking the address of the member function
front() of range.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3123




Created an attachment (id=481)
Zip fixes

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3123





 The problem looks to be a question of whether range.front is an lvalue or not. 
 When range.front is an lvalue, DMD interprets &range.front as taking the
 address of the front element of the range.  When range.front is not an lvalue,
 DMD interprets &range.front as taking the address of the member function
 front() of range.
The problem is that Proxy tries to store a pointer to the fronts of each range. In the case of these 'lazy' ranges, the pointer makes no sense. I have uploaded a new version of Zip which I think solves this problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 25 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3123





 Created an attachment (id=481) [details]
 Zip fixes
I changed Proxy to store by reference for ranges supporting reference return types and by value otherwise. I also changed Zip to only support back and popBack when all ranges are bidirectional. And I also changed Proxy.at to return by reference. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 25 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3123


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 26 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3123


David Simcha <dsimcha yahoo.com> changed:

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



Fixed SVN.

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