On 4/3/2017 2:38 PM, David Nadlinger wrote:
On Monday, 3 April 2017 at 21:00:53 UTC, Walter Bright 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.

You could use an exception instance allocated in TLS (which is, in fact, what
Weka does in large parts of the code). This should be perfectly memory safe,
although there are of course implications for exception chaining. (By default,
you'll still get an allocation for the associated TraceInfo, but you can disable
that.)

Of course, this is not to say that a nicer/more general solution wouldn't be
appreciated.

 — David

Using a singleton in TLS is indeed memory safe, as long as you don't do things like keep a reference to it around and expect it not to change.

Reply via email to