Proposal: Exceptions and @nogc

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 3 23:52:02 PDT 2017


Am Mon, 03 Apr 2017 14:31:39 -0700
schrieb Jonathan M Davis via Digitalmars-d
<digitalmars-d at puremagic.com>:

> On Monday, April 03, 2017 14:00:53 Walter Bright via Digitalmars-d
> wrote:
> > The idea of this proposal is to make a nogc program much more
> > achievable. Currently, in order to not link with the GC, you can't
> > use exceptions (or at least not in a memory safe manner). A
> > solution without memory safety is not acceptable.  
> 
> Yeah, the simple fact that you can't allocate exceptions in @nogc
> code is crippling to @nogc, and a lot of code that could otherwise be
> @nogc can't be because of exceptions - though the exception message
> poses a similar problem (especially if you'd normally construct it
> with format), and I don't know how you get around that other than not
> using anything more informative than string literals. Unless I missed
> something, this proposal seems to ignore that particular issue.
> 
> - Jonathan M Davis
> 

Allocate the string using an Allocator, free in the Exceptions ~this?

This has to be integrated somehow with the copying scheme though, so
you'll probably need some kind of reference counting for classes
again or duplicate the string on every copy. 

-- Johannes



More information about the Digitalmars-d mailing list