Deterministic Destruction is incorrect
haarg opened this issue · 2 comments
9.2.1 Deterministic Destruction states:
In Corinna, fields are indended to be destroyed in reverse order of
declaration, instance fields and then class (common) fields, from parent to
child. Consider the following (note that the syntax for:common
might
change):class Parent { field $one; field $two; field $three :common; } class Child :isa(Parent) { field $four; field $five :common; field $six; }The destruction order should be guaranteed to be:
$six
$four
$five
# class data$two
$one
$three
# class data
This does not make sense. Destruction of class data should not be mixed with destruction of object data. It should always happen last. Consider that normal object destruction would not destroy class data at all - it would only be destroyed during global destruction.
Sorry, didn't see this comment earlier.
Yes, you're absolutely correct. I wasn't thinking.
In the future, this might apply if classes become "first class" and the class itself can fall out of scope, but clearly that cannot apply now.
Addressed in 9.2.1.
Important: at the current time, class data will only be destroyed in global destruction. In the future, if Corinna classes can become "first class" in the Perl language, if a class can fall out of scope prior to global destruction, then yes, class data can be destroyed prior to global construction (e.g, for an anonymous class created a runtime).