What is the status of usability when using --exceptions:goto?
I'm using C++ but I haven't bothered to port exceptions and turned them off for the time being. That leaves me forced to use other exception mechanisms but they seem to have problems.
when using --exceptions:setjmp I always get this error:
lib\system\excpt.nim(585, 12) Error: only a 'ref object' can be raised
when I use --exceptions:goto I end up with a lot of
cannot jump from this goto statement to its label
if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
^
....
jump bypasses variable initialization
Shouldn't setjmp at least always work since it is the most simple and brute force to implement exceptions? What is the status of goto exceptions together with C++?
When you compile to C++, use C++'s exceptions.
Sorry, I can't.
So compile to C instead. :P
As soon as you import something from C++, then Nim automatically switches to the C++ backend.
You can also try --exceptions:quirky.
I get the same error as with setjmp
lib\system\excpt.nim(585, 12) Error: only a 'ref object' can be raised
Nim should look into if there is some way to unify exception handling with C and C++ and without relying on a library solution. In the language world, exceptions are on the way out meaning how it is implemented under the hood. Rust rejected exceptions if favor of return values but kind of stale design. Swift took the same idea and implemented it right using static type info. Herb Sutter made his famous proposal for value type "exceptions" (which are return values underneath). D are talking about adding value type exceptions. It would be nice if Nim had a similar solution for their native exceptions, not relying on C++ exceptions.
BTW. Doesn't C and C++ share the same problem with variable initialization bypass with goto?
Thank you for lecturing me on topics that you know less about than me.
I did not lecture you, however I just burned down your house.
It turns out that this is just a configuration issue with in excpt.nim.
setting --exceptions to something other than 'cpp' when using C++ backend doesn't automatically turn off C++ exceptions.
Simply: by using the options "--exceptions:setjmp --define:noCppExceptions" then it compiles and works.
Both setjmp and quiky seems to work with C++.