GC has a "barbaric" destroyng model, I think

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 12 06:07:54 PST 2015


On Thu, 12 Feb 2015 13:21:07 +0000, Paulo  Pinto wrote:

> 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.

but we have scopes and weak references in D too! i'm still enraged that i 
can't overload `new` and forced to use ugly `emplace!` and friends, but 
otherwise it's possible (albeit a little burdensome) to do refcounting 
for interfaces.

what is bad is that programmer has to be *very* careful with that. even 
seasoned programmers can made some errors here, that's why reference 
counting should be as much compiler-controlled as it can be.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150212/14049218/attachment.sig>


More information about the Digitalmars-d-learn mailing list