digitalmars.D.bugs - [Issue 5555] New: built-in associative array's length is nothrow
- d-bugmail puremagic.com (27/27) Feb 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5555
- d-bugmail puremagic.com (19/19) Feb 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5555
- d-bugmail puremagic.com (38/38) Sep 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5555
- d-bugmail puremagic.com (15/15) Jul 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5555
- d-bugmail puremagic.com (10/10) Dec 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5555
- d-bugmail puremagic.com (24/24) Apr 18 2013 http://d.puremagic.com/issues/show_bug.cgi?id=5555
http://d.puremagic.com/issues/show_bug.cgi?id=5555 Summary: built-in associative array's length is nothrow Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P3 Component: druntime AssignedTo: nobody puremagic.com ReportedBy: repeatedly gmail.com 08:35:27 PST --- I have following code: // aa is a string[string]; nothrow bool empty() const { return aa.length == 0; } I want use this code but dmd fails. Error: function hoge.Foo.empty 'empty' is nothrow yet may throw built-in AA's length() depends on _aaLen in rt/aaA.d. I think these functions should be nothrow. This issue breaks my template engine API ;( -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5555 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc There is a similar problem with pure too: int[int] aa; nothrow int foo() { return aa.length; } pure int bar() { int[int] aa2; return aa2.length; } void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5555 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|built-in associative |Built-in associative arrays |array's length is not |in pure nothrow functions |nothrow | Currently associative arrays can't be used much in pure nothrow functions: void main() pure nothrow { int[int] aa; aa.rehash; auto L = aa.length; auto x = aa.get(0, 10); auto k = aa.keys; auto v = aa.values; auto bk = aa.byKey(); auto bv = aa.byValue(); } DMD 2.055 gives: test.d(3): Error: pure function 'main' cannot call impure function 'rehash' test.d(4): Error: pure function 'main' cannot call impure function 'length' test.d(5): Error: pure function 'main' cannot call impure function 'get' test.d(6): Error: pure function 'main' cannot call impure function 'keys' test.d(7): Error: pure function 'main' cannot call impure function 'values' test.d(8): Error: pure function 'main' cannot call impure function 'byKey' test.d(9): Error: pure function 'main' cannot call impure function 'byValue' test.d(3): Error: aa.rehash is not nothrow test.d(4): Error: aa.length is not nothrow test.d(5): Error: aa.get is not nothrow test.d(6): Error: aa.keys is not nothrow test.d(7): Error: aa.values is not nothrow test.d(8): Error: aa.byKey is not nothrow test.d(9): Error: aa.byValue is not nothrow test.d(1): Error: function D main 'main' is nothrow yet may throw -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5555 Witold Baryluk <baryluk smp.if.uj.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |baryluk smp.if.uj.edu.pl 11:25:55 PDT --- Any updates? I'm trying to implement toHash() method which needs to be nothrow, and inside it I use aa.byKey or aa.keys or foreach (...; aa). Currently I cannot without some hacks. Fixes in rt.* should be relatively easy for most of this functions. Regards, Witek -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5555 lt.infiltrator gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lt.infiltrator gmail.com *** Issue 9168 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: -------
Dec 18 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5555 w0rp <moebiuspersona gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |moebiuspersona gmail.com I'd like to remind everyone of this issue. I hold a strong belief that even if the internals of associative arrays are impure, unsafe, and may throw, properties for associative arrays should "lie" about these things because they are invaluable mechanisms for implementing so many pure, safe, and nothrow algorithms. They aren't really pure because they modify global state, but so does allocating memory, which pure allows for. They aren't safe, because they rely on certain memory techniques, but these are internals that form the language. They aren't nothrow, because checking the properties of an associative array may fail, but this is as much of an unrecoverable error as an OutOfMemoryError. If the properties of associative arrays take on all of these things, it would make it possible to create an entire host of code which is pure, safe, and nothrow. (For starters, I can imagine undirected and directed graph types which meet these requirements.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 18 2013