On Wednesday, 28 June 2017 at 09:22:07 UTC, Guillaume Piolat wrote:
Deterministic destruction is a _solved_ problem in C++, and a number of users to convert are now coming from C++.

It is also in D, as long as you don't use the GC (which is inherently non-deterministic).

3. Suggest a systematic, always working, workaround (or language change such as "GC doesn't call ~this). C++ users have no difficulty having an object graph with detailed ownership schemes, that's what they do day in day out.

It's important to have a _simple_ story about resource release, else we will talk about "GC" every day, and hearing about "GC" is bad for marketing.

Requirement: Do not allocate using the GC
Option 1) Use structs with `@disable this`, `@disable this(this)`, and a destructor that checks whether the resource reference is != invalid resource reference before trying to release.
Option 2) Use classes with simple constructor/destructor layout.
If you want to integrate a check that the requirement holds (with either class or struct), put `if (gc_inFinalizer) throw SomeError` into the class/struct destructor

Reply via email to