stevan / p5-MOP

A Meta Object Protocol for Perl 5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decouple abstract-ness and required methods

stevan opened this issue · comments

Currently, via the mop::role API, we define abstract-ness with two different criteria. First, does a class/role have any required methods? This is the more classic definition of "abstract" in which the class/role is not complete and therefore cannot be instantiated. Second, is the class/role explicitly marked as "abstract"? This is the case where you, the programmer, decided the class was abstract.

By making the is-abstract check have to look at the set of required methods, we slow down all instance construction. If instead we only looked at the $IS_ABSTRACT flag/package-variable, and relied on the fact that required methods would be checked at compile time and set the $IS_ABSTRACT accordingly, then we could speed things up and avoid a lot of runtime meta layer calls.

I also think that this is better left as a choice to the object-system developer, the mop itself should not enforce this.

Notes in the source: https://github.com/stevan/p5-mop/blob/master/mop/lib/mop/role.pm#L88

We've removed abstractness from the MOP, this is no longer relevant.