Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I'm not yet sure which operators perls overloading can handle

AFAIK All of them. Even the handling of different quoting types in the code.

Its a fallback system however. If the operator is explicitly defined then that definition is used, otherwise if overload can syntheisze the behaviour of the opertor in question by using a different defined operator then it will do so. For instance defining '<=>' and 'cmp' with the normal settings (the fallback behaviour is configurable) iirc will cause all of the equivelency operators, numeric and string, behavior to be overriden.

One thing you have to watch out for however is the common debugging habit of stringifying references by concatenation. The "" operator can cause some suprising results.

A fairly common use of overload might be

use overload qw("" stringify <=> num_comparision cmp str_comparison);
When the right hand side is a string as it is in this case then the handler is expected to be a method of that name called against the object. Otherwise a coderef is expected.

The overload docs were written by a mathematician which is why they are relatively incomprehensible to mere mortals like us. Its incredibly easy to miss details or become confused when reading that document. I think I've read it at least ten times and I still find things I haven't seen before.

--- demerphq
my friends call me, usually because I'm late....


In reply to Re: Re: Re^3: $bad_names eq $bad_design by demerphq
in thread $bad_names eq $bad_design by Ovid

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (13)
    As of 2014-07-23 11:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (140 votes), past polls