I've been experimenting with the -betterC switch and stumbled
upon something that didn't quite make sense to me.
I've put together a small example [1] of Win32 code with a window
callback that has to be nothrow as per the definition of WNDPROC
somewhere in core.sys.windows. However, calling anything from
within the window callback not marked as nothrow will result in a
compile error. This behavior is expected for regular D code and
there are many ways to fix the code so the compiler no longer
emits the error. What bugs me is the following.
According to the docs, exceptions "won't work":
From https://dlang.org/spec/betterc.html#consequences
As no Druntime is available, many D features won't work. For
example:
[...]
7. Exceptions
[...]
To me, this means it should be impossible to write -betterC code
that throws exceptions. So shouldn't -betterC imply nothrow on
all functions by default? Is this a compiler bug? If not, in what
way is the explicit nothrow attribute still useful for -betterC?
[1]
https://gist.github.com/Manuzor/81cc01d57543202d68eab5a84d944027