digitalmars.D.bugs - [Issue 8882] New: map, filter, iota and zip in pure (and nothrow) functions
- d-bugmail puremagic.com (46/46) Oct 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8882
- d-bugmail puremagic.com (10/10) Oct 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8882
http://d.puremagic.com/issues/show_bug.cgi?id=8882 Summary: map, filter, iota and zip in pure (and nothrow) functions Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2012-10-23 16:43:44 PDT --- This is not an enhancement request, I think of it as a bug report. This is a spinoff of Issue 8878 To make functional programming in D a better experience, the following functions should be usable in a pure (and possibly nothrow) context: import std.algorithm: map, filter; import std.range: iota, zip; void main() pure nothrow { auto m = map!q{a * a}([1, 2, 3]); auto f = filter!q{ a > 1 }([1, 2, 3]); auto i = iota(1, 10, 2); auto z = zip([1, 2, 3], [10, 20, 30]); } DMD 2.061alpha gives: test.d(4): Error: pure function 'main' cannot call impure function 'map' test.d(5): Error: pure function 'main' cannot call impure function 'filter' test.d(6): Error: pure function 'main' cannot call impure function 'iota' test.d(7): Error: pure function 'main' cannot call impure function 'zip' test.d(4): Error: map is not nothrow test.d(5): Error: filter is not nothrow test.d(6): Error: iota is not nothrow test.d(7): Error: zip is not nothrow test.d(3): Error: function D main 'main' is nothrow yet may throw Note: zip() accepts a StoppingPolicy, so this can't be nothrow: import std.range: zip, StoppingPolicy; void main() pure { auto z = zip(StoppingPolicy.requireSameLength, [1,2,3], [10,20]); foreach (t; z) {} // throws } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 23 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8882 bioinfornatics <bioinfornatics gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bioinfornatics gmail.com --- Comment #1 from bioinfornatics <bioinfornatics gmail.com> 2012-10-24 11:16:25 PDT --- *** Issue 8879 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: -------
Oct 24 2012