Perl-Apollo / Corinna

Corinna - Bring Modern OO to the Core of Perl
Artistic License 2.0
157 stars 19 forks source link

Destructor Feedback #7

Closed Ovid closed 2 years ago

Ovid commented 4 years ago

Use this issue to provide feedback on the Cor Destructor Proposal.

haarg commented 4 years ago

Roles will need some accommodation here. The pattern for handling destruction in Moo/Moose is:

sub DEMOLISH {}
after DEMOLISH => sub { ... };

This is not particularly obvious, and relies on method modifiers, which aren't intended to be supported in Cor.

DEMOLISH is not called like a normal method. It may make more sense to stop defining them as methods. DESTRUCT could be more like a keyword defining a callback, rather than a method.

maros commented 3 years ago

Currently in Perl i find it very hard to work with DESTROY (or DEMOLISH for that matter) since the order in which "slots" are destroyed varies each time (probably due to random hash order). Ensuring the same order, based on the order in which the slots were defined would make the destruction much more predictable.

(and i believe that using ${^GLOBAL_PHASE} instead of a dedicated global-destruction argument is perfectly fine)

Ovid commented 2 years ago

Closing old tickets because the MVP has been accepted. We'll start fresh with real code.