in reply to Re: Read all the file path having text document
in thread Read all the file path having text document

"in Perl you usually wouldn't use prototypes, unless you have a very good reason."
Why? What is the downside? Is there some guidance document somewhere?
I can see that for 'short' scripts (all on a single page); but what about 4000 lines of Perl spread across 10-12 packages?

To me; prototyping keeps me from making subtle design changes (just 1 extra arg, in this special case) that are not documented, and probably will cause maintenance problems later.
I learned to even like C++'s mangled namespace to use argument types as overloading specifiers.

I think it is inappropriate to pooh-pah someone for using good software engineering technique. Are 'strict', 'warning', and maybe 'taint' really not needed either?

  • Comment on Re^2: Read all the file path having text document

Replies are listed 'Best First'.
Re^3: Read all the file path having text document
by Joost (Canon) on Nov 30, 2008 at 15:35 UTC
    To me; prototyping keeps me from making subtle design changes (just 1 extra arg, in this special case) that are not documented, and probably will cause maintenance problems later.
    If you're doing that, you don't understand what prototypes do (and this is common, and one of the reasons for the general rule that you shouldn't use them unless you've got a good reason).

    Prototypes in perl convert arguments and allow short-cuts in the calling code. The "checking" of the arguments only happens as a side effect, and you'll only get warnings/errors if the arguments cannot get converted. This probably means you'll have subtler bugs, not less.

    See also Are prototypes evil?, for example

      Ok ... Perl prototypes are really "context casts", and that seems dangerous ( I will be commenting out all of mine). Not the 'prototype' that the software industry has been using for the last 30 years, across hundreds of languages. But, I do hope that 'addition' is a mathematical operation and not a name for shuffling of the bits with truncation of the overflows.

      Bad re-use of nomenclature.

      EOM

Re^3: Read all the file path having text document
by almut (Canon) on Nov 30, 2008 at 15:55 UTC