www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5250] New: Pure std.typecons.Tuple

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

           Summary: Pure std.typecons.Tuple
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This D2 program seems to show that a strongly pure function can't generate and
return a std.typecons.Tuple, but I'd like it, if possible:


import std.typecons: Tuple;
pure Tuple!int foo() {
    return Tuple!int(0);
}
void main() {
    assert(foo()[0] == 0);
}


dmd 2.050 shows the error:
test.d(3): Error: pure function 'foo' cannot call impure function 'this'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5250




The same is true for "nothrow" attribute:


import std.typecons: Tuple;
pure nothrow Tuple!int foo() {
    return Tuple!int(0);
}
void main() {
    assert(foo()[0] == 0);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5250


bearophile_hugs eml.cc changed:

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



Yay, fixed in DMD 2.054. Pure Tuples are useful in functional-style
programming.

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