Truly @nogc Exceptions?
Steven Schveighoffer
schveiguy at gmail.com
Thu Sep 20 00:58:38 UTC 2018
On 9/19/18 7:53 PM, Seb wrote:
> On Wednesday, 19 September 2018 at 21:28:56 UTC, Steven Schveighoffer
> wrote:
>> On 9/19/18 5:16 PM, Steven Schveighoffer wrote:
>>> One further thing: I didn't make the sink version of message @nogc,
>>> but in actuality, it could be.
>
> We recently introduced support for output ranges in the formatting of
> Phobos:
>
> https://dlang.org/changelog/2.079.0.html#toString
>
> Output ranges have the advantage that they could be @nogc and because of
> the templatization also @safe.
I don't think that will work here, as Throwable is a class.
All I can think of is that you would have 2 versions, a @nogc one that
takes a @nogc delegate, and one that is not.
Of course, your exception type could define something completely
separate, and you can deal with it in your own project as needed.
If there was a way to say "this is @nogc if you give it a @nogc
delegate, and not if you don't", that would be useful. The compiler
could verify it at compile-time.
-Steve
More information about the Digitalmars-d
mailing list