in reply to Re^3: Warning for "unused sub declarations"?
in thread Warning for "unused sub declarations"?

There's never any GOOD reason to go leaving parens out. Not on maintained code, anyway. See the story on nuclear missiles and Perl.. with the mistake being blamed on an ASSUMED precedence order on an operation. Even in this example use of parenthesis would have given this user the compile time warning he was looking for. Even smarter would be to add argument expections to the prototype: sub chk_timer( $ ); But programmers like to think they are smarter than that and take risks. So do a lot of American drivers refusing to wear their seatbelts. That's ok, an ego is a precious thing, except in professional circles. If you can't program to protect against yourself, or drive wearing a seatbelt JUST IN CASE, then you have no defence when you look silly (or dead) at the end of the day. The art of programming is like self defence, mastery of self. I am not perfect.. are you?
  • Comment on Re^4: Warning for "unused sub declarations"?

Replies are listed 'Best First'.
Re: Warning for "unused sub declarations"?
by jonadab (Parson) on May 26, 2005 at 10:50 UTC
    There's never any GOOD reason to go leaving parens out. Not on maintained code, anyway.

    Really? Are you sure?

    open IN, '<', $infile or die "Cannot open infile: $!\n"; my $foo = <IN>; print "The foo value is " . $foo . ".\n";

    Or would you prefer to see it this way...

    ((open(IN, '<', $infile)) or (die "Cannot open infile: $!\n")); ((my $foo) = <IN>); (print(("The foo value is " . $foo) . ".\n"));

    As someone who has programmed in lisp, I can handle working with code like that, but it's not the most clear and Perlish style available. Some of those (parens (aren't (strictly (necessary)))), because the order of some operations is so well-established and obvious that the code is clear without them.


    "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68