|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.bugs - [Issue 3050] New: Allow exception in CTFE (patch)
http://d.puremagic.com/issues/show_bug.cgi?id=3050 Summary: Allow exception in CTFE (patch) Product: D Version: 2.030 Platform: x86 OS/Version: All Status: NEW Keywords: patch Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: rsinfu gmail.com Created an attachment (id=389) --> (http://d.puremagic.com/issues/attachment.cgi?id=389) Patch (DMD 2.030) The proposed patch implements support for throw/try/catch/finally in CTFE. Throw statement is, however, somewhat limited; new expression is not allowed, except for new Exception("msg"). Example and output: -------------------- int thrower(string s) { // The interpretor emulates throw new Exception("msg") throw new Exception("exception " ~ s); return 0; } int catcher() { try { return thrower("abc"); } catch (Exception e) { throw e; } return 0; } enum a = catcher("abc"); -------------------- test.d(21): Error: uncaught exception from catcher(): "exception abc" test.d(21): Error: cannot evaluate catcher() at compile time -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- Jun 03 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3050 --- Comment #1 from Shin Fujishiro <rsinfu gmail.com> 2009-06-04 15:37:11 PDT --- Created an attachment (id=391) --> (http://d.puremagic.com/issues/attachment.cgi?id=391) Additional patch Please apply this patch in addition to the first one. The first one allowed this problematic code: -------------------- Exception foo() { Exception r; try { throw new Exception("error"); } catch (Exception e) { r = e; } return r; } enum Exception e = foo(); -------------------- This patch fix the first patch so that a CTFE exception object cannot be used as a usual object. The only allowed use of a CTFE exception object is this: catch (Exception e) { throw e; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- Jun 04 2009
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=3050 Summary: Allow exception in CTFE (patch) Product: D Version: 2.030 Platform: x86 OS/Version: All Status: NEW Keywords: patch Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: rsinfu gmail.com Created an attachment (id=389) --> (http://d.puremagic.com/issues/attachment.cgi?id=389) Patch (DMD 2.030) The proposed patch implements support for throw/try/catch/finally in CTFE. Throw statement is, however, somewhat limited; new expression is not allowed, except for new Exception("msg"). Example and output: -------------------- int thrower(string s) { // The interpretor emulates throw new Exception("msg") throw new Exception("exception " ~ s); return 0; } int catcher() { try { return thrower("abc"); } catch (Exception e) { throw e; } return 0; } enum a = catcher("abc"); -------------------- test.d(21): Error: uncaught exception from catcher(): "exception abc" test.d(21): Error: cannot evaluate catcher() at compile time -------------------- Jun 04 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3050 --- Comment #2 from Shin Fujishiro <rsinfu gmail.com> 2009-06-04 20:42:46 PDT --- Created an attachment (id=392) --> (http://d.puremagic.com/issues/attachment.cgi?id=392) Patch: scope(success/failure/exit) Supplemental patch to get scope guard statement working in CTFE. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- Jun 04 2009
Robert Fraser <fraserofthenight gmail.com> wrote:Since scope() is defined in terms of try/finally, would it be much harder to get scope(success/failure/exit) working in CTFE? Jun 04 2009
Just wow! I wonder what else can D community do since DMD has full source code available now. Jun 05 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3050 --- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2009-07-14 03:02:14 PDT --- Wow! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- Jul 14 2009
|