More radical ideas about gc and reference counting
via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 2 08:38:34 PDT 2014
On Friday, 2 May 2014 at 15:06:59 UTC, Andrei Alexandrescu wrote:
> On 5/2/14, 3:09 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
>> On Thursday, 1 May 2014 at 22:23:46 UTC, H. S. Teoh via
>> Digitalmars-d
>> wrote:
>>> On Thu, May 01, 2014 at 03:10:04PM -0700, Walter Bright via
>>> Digitalmars-d wrote:
>>>> The thing is, GC is a terrible and unreliable method of
>>>> managing
>>>> non-memory resource lifetimes. Destructors for GC objects
>>>> are not
>>>> guaranteed to ever run. If you do have struct with a
>>>> destructor as a
>>>> field in a class, you've got, at minimum, suspicious code
>>>> and a latent
>>>> bug.
>>>
>>> Exactly!!! This is why I said we should ban the use of
>>> structs with
>>> dtors as a field in a class.
>>
>> No, not in a class, but in any GC-managed object. It's
>> unfortunate that
>> class currently implies GC.
>
> So now it looks like dynamic arrays also can't contain structs
> with destructors :o). -- Andrei
Well, that would be the logical consequence...
But my main point was actually this:
Don't disallow destructors on classes just because they are
classes, but disallow them when they are not guaranteed to be
called (or calling them is troublesome because of
multi-threading), i.e. GC.
More information about the Digitalmars-d
mailing list