This definitely seems like a worthwhile WTDI. However, I think I'd rather see the following syntax instead of your define_attributes:
package Bar; use BaseClass { name => '$', values => '@', anarrayref => '*@', };
Copy from base the ability to automatically add BaseClass.pm to @Bar::ISA. Copy from Class::Struct the syntax of specifying elements. (Although, personally I'd prefer a slash instead of an asterisk to represent refs and the ability to use '[ ]' and '{}' -- it's more Perlish that way.)
This way, you've combined the BaseClass, @ISA, and define_attributes statements into one handy statement that's terse but clear.
Then, to handle inheritance, you could use something like this:
And now the object would have the attributes from Foo and Fub, as well as the ones specified in the anonymous hash.use BaseClass qw(Foo Fub) { name => '$', };
-- Frag.
In reply to Re: Idea on a Base class API
by frag
in thread Idea on a Base class API
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |