GC has a "barbaric" destroyng model, I think

Paulo Pinto via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 12 05:21:07 PST 2015


On Thursday, 12 February 2015 at 09:41:50 UTC, ketmar wrote:
> On Thu, 12 Feb 2015 09:26:12 +0000, Kagamin wrote:
>
>> That's a repetition of C++ atavism, that resource management 
>> == memory
>> management. IStream is a traditional example of a GC-managed 
>> object,
>> which needs deterministic destruction, and not because it 
>> consumes
>> memory, but because it encapsulates an unmanaged resource, it 
>> has
>> nothing to do with memory management, malloc and free.
>
> p.s. istream example is bad. what it does is simply 
> highlighting the fact
> that there is no way to do deterministic management with GC.

Other languages manage to do it with scopes (e.g. using/lambda 
expressions) and phantom/weak references.

The only downsize it that it isn't as simple as a C++ destructor.

--
Paulo


More information about the Digitalmars-d-learn mailing list