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

           Summary: Sequence example alternative
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: andrej.mitrov...@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 2010-09-03 
10:05:39 PDT ---
From: http://www.digitalmars.com/d/2.0/phobos/std_range.html#Sequence

// a[0] = 1, a[1] = 2, a[n] = a[0] + n * a[1]
auto odds = sequence!("a[0] + n * a[1]")(1, 2);

This has been reported in bug 3181 for not compiling.

But there's a workaround. If I use the "a.field[]" syntax instead of "a[0]",
then the original example in the documentation works:

auto odds = sequence!("a.field[0] + n * a.field[1]")(1, 2);


There are also some weird bugs in the sequence unittest in range.d. Apparently
you can't call both Sequence and sequence in the same code. That code is
commented out with "@@BUG", but there's no bug number so I guess it wasn't
reported yet, or maybe someone is already working on it.. 
But anyway, here's the gist of it:

import std.range;
import std.typecons;

void main()
{
    alias Sequence!("a.field[0] + n * a.field[1]", Tuple!(int, int)) Gen;
    auto y = sequence!("a.field[0] + n * a.field[1]")(0, 4);
}

C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\range.d(2459): Error
: this for _cache needs to be type Sequence not type Sequence!("a
.field[0] + n * a.field[1]",Tuple!(int,int))

If you uncomment either line, the example compiles.

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

Reply via email to