Thanks Jeffa. Believe me, I haven't forgotten about (jeffa) Re: A better mod (%) operator? and my reply at Re: (jeffa) Re: A better mod (%) operator? still stands. I've frequently used overload for individual and groups of math and boolean operators, probably because you gave me 'boost up' back then.

However, whenever I've tried to use it with the more esoteric operators, notably, '""' and '0+' (Thanks Zaxo) but also "{}", "[]", I've often found myself fighting the compiler to get the effects I want ... as opposed, perhaps, to the effects that overload is designed to give me.

I've read the overload docs so many times I almost know them verbatim, but I still get caught out every time I try to use it....as at Temporarily disabling overloaded operations..

Individually, I can make them work fine (mostly:), but when I try to use large scale overlaoding, especially in classes that are not simple classes, but (for example) use inheritance, or even tieing, things start going astray.

So, having looked around at a few complex uses like the Math::Big* suite, but found it difficult to follow as the are inherently complex beasties without the overloading, they also aren't pure perl, which makes it more difficult to trace stuff through in the debugger, I thought I'd ask if anyone knew of a fairly simple, but (more) complete worked example.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail


In reply to Re: Re: Using overload. Any complete (simple) examples? by BrowserUk
in thread Using overload. Any complete (simple) examples? by BrowserUk

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.