Problems? Is your data what you think it is? | |
PerlMonks |
Re: What's broken in Perl 5? (attributes)by Anonymous Monk |
on May 02, 2005 at 13:39 UTC ( [id://453226]=note: print w/replies, xml ) | Need Help?? |
In my humble opinion the attributes (per attributes.pm) is broken. The first and perhaps most obvious and omnipresent problem is that there's no clean way to flag a variable or subroutine with an attribute. If I do my $foo :Foo;, how do I later see if $foo has the attribute Foo? The second problem is subroutine attributes. In the attribute handler (MODIFY_CODE_ATTRIBUTES) the subroutine is not yet fully defined. There's even no way to distinguish between anonymous subroutines and named subroutines. It doesn't even have an internal name yet, no flags set, no stash. Nor does it have any eventual prototype set. Pretty much nothing. The attribute handler is called too early. This is by current design, but a broken design imho. This is the reason Attribute::Handlers resorts to a (broken) INIT workaround. While Attribute::Handlers was a good initiative and helped to show the niceness of attributes it doesn't solve the next major issue: namespaces for attributes. Attribute::Handlers rather works against a solution in that it encourages one to create global attributes. When I search CPAN a while back I found 28 modules that defined attributes. Out of these 26 polluted the UNIVERSAL namespace. I see a lot of potential in attributes. As their current implementation is so poor I personally frown upon their usage. Therefore I've been working on a set of modules that aim to make attributes usable and a working tool to write even nicer Perl code. In large, my modules aim to
If anyone is interested please contact me and I'll try to free off time during the next weeks to write an RFC to post here on Perl Monks. I'm of course happy to receive any ideas by mail too. Regards,
In Section
Seekers of Perl Wisdom
|
|