Beefy Boxes and Bandwidth Generously Provided by pair Networks
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 reply to What's broken in Perl 5?

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

  • provide namespace scoping and import/export,
  • allow reflective programming for subroutines, and
  • free the programmer from the need to use a module to define attributes.
Of course, they introduce their own set of caveats and annoyances, but they'll at least fix most of the bugs and annoyances with Attribute::Handlers and hopefully the new caveats aren't as serious.

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,
J Lodin (LODIN at CPAN)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://453226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-29 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found