Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Monday January 12, 2004
03:16 AM

Big name, little problem

[ #16772 ]

I thought I might start to classify bugs---create a taxonomy, so to speak, that perhaps gives a latin name to every species.

I could start with the one I beat my head against today. I wanted to print some formatted text.

use Text::AutoFormat;
 
$text = autoformat( $entry, { ... } );
 
print $entry;

Why does this not work? I just want to format some text. For 20 minutes or so I fiddled with all sorts of things to figure this out, and no matter what I did, the text still came out in a big jumble.

Can you spot the problem?

If I want to print the value of $text, I should use $text in the print statement. It seems so simple, but today that eluded me. Not only that, I know I have made this same sort of error many, many times in my life. It deserves a name---a really important name---to elevate it beyond its mere stupidity into some sort of software engineering jabberwocky worthy of conference presentations, journal articles, and high brow discussion.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • It deserves a name---a really important name---to elevate it beyond its mere stupidity into some sort of software engineering jabberwocky worthy of conference presentations, journal articles, and high brow discussion.

    Side effects [ic.ac.uk] considered harmful?

    • Not a side effect. The variable doesn't get modified....
      --

      --
      xoa

      • use Text::AutoFormat;
        $text = autoformat( $entry, { ... } );
        print $entry;

        It looks to me that there was some (perhaps unconscious) expectation that $entry was going to be modified by the call to autoformat(). Perhaps "Unconscious/Anticipatory Side-Effect Considered Harmful" would be better? If not it might be a useful topic for some postmodern criticism :-)

        <aside>Ain't it nice to be able to comment in brian's journal?.../me wonders how long this can last.</aside>

        • I just figured it was a brainfart when adding the autoformat call, that the code was originally something like:
          $entry = get_the_entry();
          print $entry;
          and brian said "Hey, I want formatting", and added the autoformat line.
          $entry = get_the_entry();
          $text = autoformat( $entry, {...} );
          print $entry;
          At least, that's usually how I get in this situation...
          --

          --
          xoa

          • "Brainfart" now that's "worthy of high discussion" :-) Perhaps "Brainus Farticus" would lend it more latin flavor (or not). Seriously though, brian's error looked to me like it was coming from too much C programming, a la...

            stpcpy (char *to, const char *from)

            "C Considered Harmful"? Nah...

        • I can see Ed's point, and if I had showed the progression of my thought, it would have been more clear (or maybe less). I wanted to use $text, but something earlier was messing up, so I put $entry into the string, although it was ugly, unformatted HTML. I never changed it back to $text.

          [I'll keep comments on from now on. At the beginning I was just afraid of a bunch of people saying really stupid things (like on other blog/journal sites, but use.perl does not really have a lot of that]
  • for example:

    (Not resulting directly from an act or cause, but more or less remotely connected with or growing out of it; as, indirect results..)

    or

    Indirect, or Negative, demonstration (called also reductio ad absurdum), in which the correct conclusion is an inference from the demonstration that any other hypothesis must be incorrect.

    So, we have an Indirect Indefinite, or as they say in the business, a 'case of mistaken definity'.

  • This seems to be a sibling-bug to:
    use warnings;
    $value = 42;
    print "$valu is the answer.\n";
    I think that for short programs, both bugs might be caught by use warnings; but in long programs, your bug is more likely to be undetected becase both names will be reused.

    I would call your bug something like "unintended discarded outputs." Which doesn't sound very high-falutin', but oh well.

    --

    -DA [coder.com]