On Monday, 19 June 2017 at 10:13:33 UTC, Ali Çehreli wrote:
I know that there are efforts towards @nogc exceptions but I
think @nogc should somehow related only to the normal operation
of code. Since exceptions are for error cases, perhaps they
shouldn't have an effect on whether a function is @nogc.
This strikes me as making a lot of sense. You can compare it to
the @system, @trusted and @safe trio, where @system is the
default and @trusted could be verbosely translated as
Transferring this to GC, you could have @gc (the default), @nogc
(the @safe equivalent) and the @trusted equivalent:
@gc_code_that_is_acceptable_to_be_called_in_nogc_code_as_an_exception_to_the_rule. I'll abbreviate this as @gc78 until there is a better name.
With this, exceptions can be defined to be @gc78 to make them
work in @nogc code: As exceptions are exceptional, one can argue
that it is OK for them to do exceptional things.
Also, you can write a debugging function that uses string
concatenation and writeln inside a DebugCondition, mark it as
@gc78 and you'll still be able to call it in @nogc code. This
won't cause collection in release versions.