October 24, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #10 from bearophile_hugs@eml.cc 2012-10-24 10:36:19 PDT --- One more test case: enum En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 24, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #11 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-24 10:58:10 PDT --- http://dpaste.dzfl.pl/f4e35e84 More tests welcome! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #12 from bearophile_hugs@eml.cc 2012-10-24 17:20:39 PDT --- (In reply to comment #11) > http://dpaste.dzfl.pl/f4e35e84 Please attach this in Bugzilla :-) > More tests welcome! Is this supported? enum En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #13 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-24 17:32:54 PDT --- Created an attachment (id=1153) d (In reply to comment #12) > Is this supported? > enum En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); Yes. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #14 from bearophile_hugs@eml.cc 2012-10-24 17:43:17 PDT --- (In reply to comment #13) > > Is this supported? > > enum En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); > > Yes. Then I suggest to add it to your tests, because it's not present. Your tests contain code like: En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #1153|0 |1 is obsolete| | --- Comment #15 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-24 17:56:41 PDT --- Created an attachment (id=1154) code (In reply to comment #14) > (In reply to comment #13) > > > > Is this supported? > > > enum En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); > > > > Yes. > > Then I suggest to add it to your tests, because it's not present. > > Your tests contain code like: > > En[][] m1 = to!(En[][])([[10, 30], [30, 10]]); Ah it took me a while to realize you were looking for CTFE ability. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #16 from bearophile_hugs@eml.cc 2012-10-24 18:38:41 PDT --- (In reply to comment #15) > Ah it took me a while to realize you were looking for CTFE ability. Sorry for not being more clear. Another significant test case, this is useful in many simulations and games, to write safe tables and start conditions: enum Code : char { A='A', B='B', C='C' } void test() { ... const code = to!(Code[][])(["ABCCBA", "BBAA"]); with (Code) assert(code == [[A, B, C, C, B, A], [B, B, A, A]]); } The main problem with this is that you receive conversion errors only at run-time, and in D the problem with array compile-time constants is that the compiler re-creates them every time where you use them. So they are not so useful. ------------------ Unfortunately this is not yet allowed because to!() is not pure: immutable code = to!(Code[][])(["ABCCBA", "BBAA"]); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #1154|0 |1 is obsolete| | --- Comment #17 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-24 18:49:26 PDT --- Created an attachment (id=1155) new Without purity it works ok though. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #18 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-25 10:05:39 PDT --- (In reply to comment #17) > Created an attachment (id=1155) [details] > new > > Without purity it works ok though. Not much (any) response in D NG. I could try and make a pull and see what folks have to say. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8143] Safe std.conv.to enum conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8143 --- Comment #19 from bearophile_hugs@eml.cc 2012-10-25 10:25:29 PDT --- (In reply to comment #18) > Not much (any) response in D NG. I could try and make a pull and see what folks > have to say. OK. -- 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