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

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)


In reply to Re: What's broken in Perl 5? (attributes) by Anonymous Monk
in thread What's broken in Perl 5? by tlm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.