Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Well, yes, sometimes. Especially since I see so much code trying to emulate this behaviour instead, checking if the first argument is a hashref, do this, if it is an arrayref, do that, if it is a coderef, do that etc.

Technically it would not be so much of a difference in most cases, codewise, if you had prototypes (*not* the normal Perl prototypes) do this, as most such overloaded functions do some quick reformatting and then passes the data on to the next in line. So it is really the same, but it is cleaner and easier to read/write. For those that are used to it. :)

But I don't really like that feature when I don't have default arguments to go with it (like C has and Java don't). So that would have to be included, because even though the workaround is simple, it is annoying. :)

Apart from the multimethod module suggested above (which looks pretty cool too), I guess one could do some "preprocessing" magic with a Filter module or something as an alternative. Like I said, having that kind of methods is very similar to do typechecking inside one function instead, so a source filter could probably accomplish this. If someone is bored enough to write it. :)

You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

In reply to Re: Prototypes allow overloading subs? by Dog and Pony
in thread Prototypes allow overloading subs? by BUU

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (3)
    As of 2018-01-21 20:59 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (230 votes). Check out past polls.