On Thursday, 24 May 2018 at 18:51:31 UTC, Mike Franklin wrote:
I'm trying to find a way to declare a block of code `nothrow:` when compiling with -betterC, but not `nothrow` when not compiling with -betterC.

The solution is needed for this PR: https://github.com/dlang/druntime/pull/2184/files#r188627707
[...]
Given that the PR above is for object.d, I can't turn the entire object.d source file into a string and conditionally mix that in.
 Does anyone have a solution to this?

Thanks,
Mike

I think conditional application of attributes would be something useful. Something like this:

version (D_BetterC)
    enum BetterC = true;
else
    enum BetterC = false;

nothrow!(BetterC):
...

Of course that would require a DIP though

Reply via email to