Go, D, and the GC
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 5 00:40:34 PDT 2015
On Monday, 5 October 2015 at 07:01:35 UTC, Dmitry Olshansky wrote:
> Supposed to be the case for structs except for any bugs.
>
Not on the heap. There are many cases where the destructor won't
run and it is allowed by spec. We should do better.
>> Until then, no, D's mechanisms for non-heap allocations are
>> vastly
>> inferior to C++'s.
>
> Well need some helpers for RC/on stack classes plus kill that
> horrible extra monitor field.
>
> Otherwise I fail to see how. Plus with D's everything is
> movable by default. I mean I can memcpy D's structs just fine
> _by spec_ provided that I bitblit T.init over the source.
>
> In C++ you can't - not only self-references are permitted but
> also there is no T.init so there is no bit-pattern that is
> guaranteed to not explode in dtor.
>
Guaranteed construct/destruction is actually a desirable feature
IMO. You get all kind of extra case int he dtor to care for when
you can't ensure proper construction, and it is not always
possible to have a meaningful .init value, leading to many
useless runtime checks or an invalid dtor.
More information about the Digitalmars-d
mailing list