Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

You know, I just remembered something. I happened to mention that in my entire time using the source filter at my previous place of employment, only one bug bit me. I think it's worth looking at.

The filter allowed method signatures, but it did not do multi-method dispatch, so it was far more limited in scope than mine. One thing it did do that mine does not is create prototype stubs for the functions. So this:

sub foo($bar) { ... }

Became this (more or less):

sub foo($); sub foo { my ($bar) = @_; ... }

Unfortunately, because it's difficult to distinguish a method from a normal subroutine, it created those prototypes for methods. With methods they are a almost a no-op. One day I had a method in a class that was probably not needed as there was a suitable method in a base class. In case I was wrong, I decided to comment out the method instead of deleting it. Can you spot the resulting bug?

sub foo($$); # sub foo($self, $bar) {...}

This fails horribly when I do $object->foo($stuff) because Perl sees that &foo is defined in the current symbol table and then tries to call it, but since there is no subroutine, it dies with an "Undefined subroutine" warning, even though I clearly had that method in a base class.

That was a very difficult bug to track down and it caused a lot of confusion. One would think that this merely reinforces the "source filters are always bad" camp, but in reality, this bug stemmed from our not using Filter::Simple but instead relying on the older Filter::Util::Call. Had we used Filter::Simple, we would have filtered only on code and the one bug never would have bitten us. This module saved us so much time in development, though, that the time wasted tracking down this one bug was easily offset by the benefits gained by all developers using it.

Cheers,
Ovid

New address of my CGI Course.


In reply to Re^2: Use method/function signatures with Perl by Ovid
in thread Use method/function signatures with Perl 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 meditating upon the Monastery: (12)
    As of 2014-09-23 13:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (222 votes), past polls