On 5/18/22 11:35, Steven Schveighoffer wrote:
> Structs that get put into classes have to run their destructors
> properly, otherwise, you will have horrible inconsistencies.
Does that suggest a different guideline: "Careful with structs in
classes." That goes against orthogonality (independence). I should not
care where a struct type is used. Or, the way to use it properly should
be handled by the struct. (Continuing below.)
> You can use the GC.inFinalizer to check if you are concerned about using
> the GC in your struct dtors.
Is that the guideline for most usability then? struct destructors must
check for GC.inFinalizer because they may be used in a class. This
doesn't sound useful either.
Perhaps my struct example should have allocated the "farewell" string
before the destructor. And then this renders struct destructors almost
like class destructors: Don't allocate in the destructor.
Something is fishy here. :)
Ali