Best way to manage non-memory resources in current D, ex: database handles.

Chad Joan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 8 17:31:35 PST 2017


Awesome, thank you!

On Thursday, 9 March 2017 at 00:47:48 UTC, Adam D. Ruppe wrote:
> Now, if you forget to scope(exit), it is OK, the garbage 
> collector WILL get around to it eventually, and it is legal to 
> work with C handles and functions from a destructor. It is only 
> illegal to call D's garbage collector's functions or to 
> reference memory managed by D's GC inside the destructor. C 
> pointers are fine.

It's good to have this confirmed.  I'm always a bit trepidatious 
around destructors.

Oooh, and it looks like there is more information in the language 
spec about @disable on struct constructors and postblits now 
(compared to the previous time I tried to learn about that 
feature).  So between that and your example, I think I have a 
feel for how to use that.  Thanks.

Have a wonderful day!


More information about the Digitalmars-d-learn mailing list