To clarify, when I use dispatch hashes, I almost always store anonymous functions in them. I don't like taking references to named subs for dispatch hashes, it requires me to keep the refs and subnames in sync and offends my sense of Once And Only Once. I should have mentioned that from the get go.. that's the basis for saying the space waste argument is invalid.
Last but not least, the programmer defined hash table has to be maintained manually as new actions are added, old ones deleted or names are changed.

Ah, but that's the problem! I have to take care that other stuff the user should not know about does not become available via symref call as I add it. With the hash, it's obvious: nothing I haven't put in there can be reached. Period.

And once you consider my omitted assumption (mea culpa, it does make a difference to my argument and should have been stated explicitly) that I'm storing anonfuncs in the hash, then there's nothing less automatic about it. Instead of writing sub action_eatfoot {}, I type eatfoot => sub {} and that's it.

Makeshifts last the longest.


In reply to Re^7: Naming Subs by Aristotle
in thread Naming Subs by eoin

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.