Replies: 3 comments 1 reply
-
In practice in perl every stash already has the In particular we could define one more to say "this stash is a class", and then add more fields to the |
Beta Was this translation helpful? Give feedback.
-
I think the list of class variables (package variables) is needed. |
Beta Was this translation helpful? Give feedback.
-
Current Implementation (2022-08-17)A class is a stash, with additionally the In this case, the /* The following fields are only valid if we have the flag HvAUXf_IS_CLASS */
AV *xhv_class_adjust_blocks; /* CVs containing the ADJUST blocks */
PADNAMELIST *xhv_class_fields; /* PADNAMEs with PadnameIsFIELD() */
PADOFFSET xhv_class_next_fieldix; These fields:
APIA regular package stash is converted into a class stash by calling: void class_setup_stash(HV *stash); Once parsing is complete (at the end of its inline block, or at the end of the containing scope for unit classes), there is another function to call: void class_seal_stash(HV *stash); (Currently this function does nothing, but from experience on Fields and ADJUST blocks are added by: void class_add_field(PADNAME *pn);
void class_add_ADJUST(CV *cv); These two API functions implicitly operate on the class stash in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How should classes actually be represented?
Since a "class" is still a "package", I feel the way forward is to still back them by an HV storing the stash. It then requires a place to store all the extra data about that class.
Inspired by
Object::Pad
, the sorts of data that would be required might includeAdditionally, for true classes:
And for roles when we get there:
In addition to those fields of actual data, the
Object::Pad
implementation also stored quite a bit more derived information from those, partly for performance reasons.Beta Was this translation helpful? Give feedback.
All reactions