www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is anything being done about exceptions & nogc?

reply "weaselcat" <weaselcat gmail.com> writes:
Hi,
the biggest blocker to converting a _lot_ of code to  nogc is 
exceptions.
Has there been anything proposed to help alleviate this? I 
couldn't find anything.

thanks.
Apr 09 2015
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
The most serious proposal I saw was making a reference counted 
class hierarchy, parallel to the GC one, which would 
automatically add and release reference. Then Throwable can 
become one of those.

Even Walter seems onboard so it might be implemented eventually.
Apr 09 2015
next sibling parent reply "weaselcat" <weaselcat gmail.com> writes:
On Friday, 10 April 2015 at 03:23:08 UTC, Adam D. Ruppe wrote:
 The most serious proposal I saw was making a reference counted 
 class hierarchy, parallel to the GC one, which would 
 automatically add and release reference. Then Throwable can 
 become one of those.

 Even Walter seems onboard so it might be implemented eventually.
is this related to or orthogonal to the recent class-ref proposals(DIP 74) from andrei and walter?
Apr 09 2015
parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Friday, 10 April 2015 at 03:36:25 UTC, weaselcat wrote:
 is this related to or orthogonal to the recent class-ref 
 proposals(DIP 74) from andrei and walter?
That's it. My understanding is that Throwable woudl be the first one that uses the new proposal.
Apr 09 2015
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/9/15 8:23 PM, Adam D. Ruppe wrote:
 The most serious proposal I saw was making a reference counted class
 hierarchy, parallel to the GC one, which would automatically add and
 release reference. Then Throwable can become one of those.

 Even Walter seems onboard so it might be implemented eventually.
Yah. DIP25 and DIP77 pave the way for DIP74, which will be the basis of refcounted exceptions. -- Andrei
Apr 10 2015
prev sibling parent "w0rp" <devw0rp gmail.com> writes:
On Friday, 10 April 2015 at 03:13:53 UTC, weaselcat wrote:
 Hi,
 the biggest blocker to converting a _lot_ of code to  nogc is 
 exceptions.
 Has there been anything proposed to help alleviate this? I 
 couldn't find anything.

 thanks.
One thing that can be done now at least is that allocating exceptions statically. So the stack trace will be off by one line and you can't pass in any runtime values to the exception, realisitcally, but you can use them in a nogc function. nogc void foo (bool value) { if (value) { static immutable exception = new Exception("message"); throw exception; } } nogc void main(string[] argv) { foo(false); // fine foo(true); // throws } Passing exceptions by value, or via reference counting, would solve exceptions without garbage collection more generally.
Apr 10 2015