In other words, you've set up a situation where $o->bar returns $o2 and blessed($o) eq $blessed($o2). So, it's mathematically provable that it literally doesn't matter* how many calls to bar() you make before the call to baz(). Furthermore, you haven't made a case as to why the author of Foo and BaseClass even cares whether or not baz() is called once or 1.233212e1234 times. So, don't worry about it until you have a reason to worry about it.

*: Well, it does matter depending on how well the VM detects that the intermediate objects can be thrown away immediately. Otherwise, you can theoretically get into a situation where you run out of RAM after enough chained calls. But, that number of chained calls would be so ridiculously high that you're just as likely to get into a problem with running out of RAM during parsing or just storing the file on disk. (Have you ever tried running a 500M .pm file?)


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

In reply to Re: Unlimited chaining (is there a way to detect this?) by dragonchild
in thread Unlimited chaining (is there a way to detect this?) by Burak

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.