Destroying structs (literally)
via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 29 03:53:11 PDT 2014
On Friday, 29 August 2014 at 06:39:20 UTC, monarch_dodra wrote:
> On Friday, 29 August 2014 at 02:38:54 UTC, H. S. Teoh via
> Digitalmars-d wrote:
>> Maybe a more relevant question might be, is there any existing
>> code that
>> *isn't* broken by structs not being destructed? (D-structed,
>> har har.)
>
> Well, this new change *could* greatly increase the amount of
> "allocation during destruction" errors we are getting. I've
> seen a fair share of these in learn, whereas a class destructor
> allocates.
>
> Structs will now also be more vulnerable to this problem too. I
> wouldn't be surprised if this pull instantaneously introduced a
> fair amount of breakage in client code.
Jacob Carlborg just recently brought this up in another thread.
Isn't it kind of consensus that calling a destructor from the GC
is not a good idea because of the restrictions that apply in this
context? Andrei even wanted to deprecate destructors for classes
because of this. Maybe a better direction would be to separate
the concepts of destruction and finalization, and introduce two
kinds of "destructors" for them.
More information about the Digitalmars-d
mailing list