digitalmars.D - Questions about the scope/Exception machinery
- Qox (13/13) May 27 2014 Hello dear D fellows :D,
- Qox (1/1) May 27 2014 ok I found a old thread about it, just delete this thread please
- Daniel Kozak via Digitalmars-d (4/5) May 27 2014 This is mail list so it is not possible to delete thread. Btw, can you
- Qox (3/3) May 27 2014 The thread is
- Mike Parker (2/8) May 27 2014 Actually, it's a newsgroup server :)
- Qox (23/23) May 27 2014 nothrow doesn't seem to work with the recent dmd compiler :(
- Qox (2/2) May 27 2014 Ofcourse this doesn't look that maintainable to me...well, then
- Mike Parker (5/7) May 27 2014 notrhow doesn't turn off exception handling. It just doesn't allow you
Hello dear D fellows :D, The problem boils down to this. I try to write a Software which should be as compact as possible. This means that i don't like to use any exception handling (which appears to be hardly integrated into the language, not that good for demoscene/OS dev stuff). So i ran into the first issue, scope expressions. When i write scope(exit) foo(); it seems that it generates exception ahndling code. Is this the case even if the called function and the callee are both nothrow decorated? Can i force the compiler to generate goto code instead of the exception handling stuff?
May 27 2014
ok I found a old thread about it, just delete this thread please
May 27 2014
Dne Tue, 27 May 2014 14:02:04 +0200 Qox via Digitalmars-d <digitalmars-d puremagic.com> napsal(a):ok I found a old thread about it, just delete this thread pleaseThis is mail list so it is not possible to delete thread. Btw, can you post link to the thread which you find.
May 27 2014
The thread is http://forum.dlang.org/thread/dtcxszysceiopzwewrpk forum.dlang.org?page=1 Title "scope(exit) without exception handling?"
May 27 2014
On 5/27/2014 9:07 PM, Daniel Kozak via Digitalmars-d wrote:Dne Tue, 27 May 2014 14:02:04 +0200 Qox via Digitalmars-d <digitalmars-d puremagic.com> napsal(a):Actually, it's a newsgroup server :)ok I found a old thread about it, just delete this thread pleaseThis is mail list so it is not possible to delete thread. Btw, can you post link to the thread which you find.
May 27 2014
nothrow doesn't seem to work with the recent dmd compiler :( I know it because _d_local_unwind2() is still called. Seems as if I need another more ugly (but still nicer than C++) solution. Mixins which jump on an error to a label...hell I love low level languages (Java is in this sense crap because they disallow [usefull] constructs like goto, templates, ...) the code will look like this (usage) mixin(onError(condition, "handling0", "handlingCallback", parameter0, parameter1)); the CTFE function onError checks the condition, if it is false it copies the parameters into variables and jumps to the label named after handling0. on the end of the function there will be mixin(errorHandling("cast(int)0", ["handling0", "handlingCallback", ...])); which writes the goto labels, handling code etc which looks like this label_handleFoo: handleFoo(); label_handling0: handlingCallback(handling0_parameter0, handling0_parameter1); return cast(int)0; a bit ugly but not so ugly as C++ ... any better ideas?
May 27 2014
Ofcourse this doesn't look that maintainable to me...well, then the C++ struct destructor way???
May 27 2014
On 5/27/2014 9:43 PM, Qox wrote:nothrow doesn't seem to work with the recent dmd compiler :( I know it because _d_local_unwind2() is still called.notrhow doesn't turn off exception handling. It just doesn't allow you to throw from a particular function. From inside a nothrow function, you can still call functions that throw, but you have to wrap them in try..catch blocks and swallow any exceptions that *are* thrown.
May 27 2014
sounds a bit like C++ handling to me, for me *personally* it misses also the point about nothrow, because it gurantues nothing...which is like in C++ and imho bad...
May 27 2014
On Tuesday, 27 May 2014 at 13:24:08 UTC, Qox wrote:sounds a bit like C++ handling to me, for me *personally* it misses also the point about nothrow, because it gurantues nothing...which is like in C++ and imho bad...It guarantees at compile time that your function will not throw an Exception.
May 27 2014