Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
October 23, 2012 [Issue 8878] New: std.range is not pure | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8878 Summary: std.range is not pure Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Optlink AssignedTo: nobody@puremagic.com ReportedBy: bioinfornatics@gmail.com --- Comment #0 from bioinfornatics <bioinfornatics@gmail.com> 2012-10-23 05:27:40 PDT --- Dear, std.range should provide some pure function as; iota -> 0 to to should give evey time the same result zip -> when it is an array (not an associative array) should be always the same result and other … this missing feature allowed developers to use the pure in many case -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8878] std.range is not pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=8878 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |jmdavisProg@gmx.com Resolution| |WONTFIX --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-23 11:22:28 PDT --- pure is inferred for templated functions. As long as the functions for the range used are pure, then the functions in std.range and std.algorithm will generally be pure. There may be some compiler bugs which make it so that that doesn't always work like it's supposed to, but pretty much zero functions in std.range and std.algorithm should be marked as pure, since whether they can be pure or not really depends on the types used with them, which is why attribute inferrence for templates was introduced in the first place. If you have an issue with a specific function with a specific type which does have pure member functions and the templated function is not being inferred as pure, then please report it with an appropriate code sample, but it would be wrong to specifically provide pure versions of functions like iota or zip. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8878] std.range is not pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=8878 --- Comment #2 from bioinfornatics <bioinfornatics@gmail.com> 2012-10-23 12:13:51 PDT --- In first thanks jonathan to your answer. Code below fail both when using pure with dmd/ldc dmdfe 2.060 => http://dpaste.dzfl.pl/65efd36e ___________________________________________ import std.range; import std.stdio; pure uint square( in int[] x, in int[] y ){ uint result = 0; foreach( item; zip( x, y ) ) result += item[0] * item[1]; return result; } int main(){ int[3] a = [0,1,2]; int[3] b = [1,2,3]; writefln( "Square of %s with %s give %u", a, b, square( a, b ) ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8878] std.range is not pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=8878 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #3 from bearophile_hugs@eml.cc 2012-10-23 14:13:32 PDT --- (In reply to comment #1) > If you have an issue with a specific function with a specific type which does have pure member functions and the templated function is not being inferred as pure, then please report it with an appropriate code sample, but it would be wrong to specifically provide pure versions of functions like iota or zip. This gives: test.d(3): Error: pure function 'main' cannot call impure function 'iota' import std.range: iota; void main() pure { iota(10); } This gives: test.d(4): Error: pure function 'main' cannot call impure function 'map' test.d(4): Error: map is not nothrow test.d(2): Error: function D main 'main' is nothrow yet may throw import std.algorithm: map; void main() pure nothrow { int[] data = [1, 2, 3]; auto r = map!q{a * a}(data); } I propose to reopen this bug report, and change its meaning and title: instead of asking for such functions to be marked as pure, to ask them to be usable in a pure (and sometimes nothrow) situations. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8878] std.range is not pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=8878 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|Optlink |Phobos --- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-23 15:25:37 PDT --- It would probably be cleaner to just create a new bug report, but you can reopen this one if you want to. Regardless, the bug as initially reported is incorrect. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8878] std.range is not pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=8878 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Component|Phobos |Optlink --- Comment #5 from bearophile_hugs@eml.cc 2012-10-23 16:44:32 PDT --- (In reply to comment #4) > It would probably be cleaner to just create a new bug report, Thank you for the answer. I have opened Issue 8882 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation