Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 09, 2011 [Issue 5555] New: built-in associative array's length is nothrow | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Masahiro Nakagawa <repeatedly@gmail.com> 2011-02-09 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: ------- |
February 09, 2011 [Issue 5555] built-in associative array's length is not nothrow | ||||
---|---|---|---|---|
| ||||
Posted in reply to Masahiro Nakagawa | http://d.puremagic.com/issues/show_bug.cgi?id=5555 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2011-02-09 09:48:44 PST --- 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: ------- |
September 18, 2011 [Issue 5555] Built-in associative arrays in pure nothrow functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Masahiro Nakagawa | 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 | --- Comment #2 from bearophile_hugs@eml.cc 2011-09-18 11:39:35 PDT --- 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: ------- |
July 05, 2012 [Issue 5555] Built-in associative arrays in pure nothrow functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Masahiro Nakagawa | 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 --- Comment #3 from Witold Baryluk <baryluk@smp.if.uj.edu.pl> 2012-07-05 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: ------- |
December 19, 2012 [Issue 5555] Built-in associative arrays in pure nothrow functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Masahiro Nakagawa | http://d.puremagic.com/issues/show_bug.cgi?id=5555 lt.infiltrator@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lt.infiltrator@gmail.com --- Comment #4 from lt.infiltrator@gmail.com 2012-12-18 17:13:09 PST --- *** 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: ------- |
April 18, 2013 [Issue 5555] Built-in associative arrays in pure nothrow functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Masahiro Nakagawa | http://d.puremagic.com/issues/show_bug.cgi?id=5555 w0rp <moebiuspersona@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |moebiuspersona@gmail.com --- Comment #5 from w0rp <moebiuspersona@gmail.com> 2013-04-18 00:27:40 PDT --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation