Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 22, 2013 [Issue 9977] New: Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9977 Summary: Function local templates should be allowed Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: k.hara.pg@gmail.com --- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-22 01:35:50 PDT --- Currently DMD accepts declaring template aggregates and functions inside functions. void test1() { struct S1(T) { T value; } auto func1(T)(T value) { return value; } static assert(is(S1!int == struct)); assert(func1(10) == 10); } But raw template declaration is not allowed. void test2() { template S2(T) { struct S2 { T value; } } // line 10 template func2(T) { auto func2(T value) { return value; } } // line 11 static assert(is(S2!int == struct)); assert(func2(10) == 10); } Output: test.d(10): Error: template definitions aren't allowed inside functions test.d(11): Error: template definitions aren't allowed inside functions Today, I think this is not reasonable limitation. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 22, 2013 [Issue 9977] Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=9977 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-22 01:43:43 PDT --- https://github.com/D-Programming-Language/dmd/pull/1919 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 22, 2013 [Issue 9977] Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=9977 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-04-22 03:02:03 PDT --- (In reply to comment #0) > Today, I think this is not reasonable limitation. Yes, especially since this: auto func1(T)(T value) { return value; } really translates into this: template func1(T) { auto func1(T value) { return value; } } At least that's what I remember. Thanks for working on this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 22, 2013 [Issue 9977] Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=9977 --- Comment #3 from github-bugzilla@puremagic.com 2013-04-22 03:38:51 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/707415dec87694c30a569dd1b67c496a9de7f648 fix Issue 9977 - Function local templates should be allowed https://github.com/D-Programming-Language/dmd/commit/006accc47fd0fb0a8299c258f66fdb0c505d9f16 Merge pull request #1919 from 9rnsr/fix9977 Issue 9977 - Function local templates should be allowed -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 22, 2013 [Issue 9977] Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=9977 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 22, 2013 [Issue 9977] Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=9977 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #4 from bearophile_hugs@eml.cc 2013-04-22 10:24:06 PDT --- In the changelog this should be underlined as a significant improvement of D. It's useful for unittests, to not pollute the module scope with template names that are used only inside the unittest. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 22, 2013 [Issue 9977] Function local templates should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=9977 --- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-04-22 10:57:37 PDT --- (In reply to comment #4) > In the changelog this should be underlined as a significant improvement of D. It's useful for unittests, to not pollute the module scope with template names that are used only inside the unittest. Yes. I've added it to the pending pull request. -- 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