Questions about the scope/Exception machinery
Qox via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 27 05:43:03 PDT 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?
More information about the Digitalmars-d
mailing list