Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Attributes are one of the things that if you don't know how to use them, you shouldn't bother with them. I once made a <code>database_method</code> attribute, to indicate to the system that a record set would be requested before entering this method and that the method knew it's main inputs would come from the stored procedure it corresponded to. </p> <p>I was using attributes to wrap the actual, specified actions with that data. So one of the really seemingly useful ideas is to wrap methods with indirection, but it was harder to make caller work, without overriding it. In the end it was much too visible as an "expert-only" feature and would have required support to trace through the arcane innards--something you want to avoid, if you write Perl in a perl-also shop.</p> <hr> <p>People may want to vote me down, but I take from the article cited by Sinan: </p> <blockquote> <p><strong>Caveats</strong></p> <p>Although this is a powerful technique, it isn't perfect. <em>The code will not properly wrap anonymous subroutines</em>, and <em>it won't necessarily propagate calling context to the wrapped functions</em>. Further, using this technique will significantly increase the number of subroutine dispatches that your program must execute during runtime. Depending on your program's complexity, this may significantly increase the size of your call stack. If blinding speed is a major design goal, this strategy may not be for you.</p> </blockquote> <p>These are <em>significant</em> drawbacks unless you're willing to override <code>caller</code>. I don't care about "blinding speed" quite as much, and I'm half-willing to try my hand at overriding <code>caller</code> to bypass any subroutine that registers itself as "DO_NOT_REPORT" -- but I have some coding foolhardiness that hasn't yet been beaten out of me, too.</p> <p>Even the article admits how ill-documented this feature is, and contains this caveat. Tell me when else it has been a good idea to use a snazzy, obscure feature? That often enough, people end up putting in the <code>UNIVERSAL</code> namespace to avoid the inheritance issue.</p> <p>(But if you do think it's a bad answer, just another downvote will give me a peer pressure badge :D) </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload