in reply to Re: What would you change?
in thread What would you change?
I am a fan of prototypes. I know it is not recommended in Perl Best Practices because of the danger of someone pushing argments into an array and then passing the array.. e.g.
returns the following error:sub prototyped( $ $ ) { print( "Arg 1: " . $_[0] . "\n" ); print( "Arg 2: " . $_[1] . "\n" ); } my @args = ( "first", "second" ); prototyped( @args );
Not enough arguments for main::prototyped
However, as much as the prototype solution is broken for this situation, I'm still a fan of prototypes.
Having prototypes has helped track down a bug in code used in production in a company whereby someone went in and modified the code adding a new parameter to each function. And then a minor bug slipped through whereby a call to one of the functions didn't provide enough arguments.
Prototypes would have caught this in the compilation phase. In fact, by adding prototypes to all the functions we caught another instance whereby a function was being called with the wrong number of parameters..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: What would you change?
by grinder (Bishop) on May 17, 2008 at 12:54 UTC | |
|
Re^3: What would you change?
by almut (Canon) on May 17, 2008 at 14:39 UTC | |
|
Re^3: What would you change?
by dragonchild (Archbishop) on May 19, 2008 at 01:51 UTC | |
by BrowserUk (Patriarch) on May 19, 2008 at 02:43 UTC | |
by dragonchild (Archbishop) on May 19, 2008 at 13:36 UTC | |
by BrowserUk (Patriarch) on May 19, 2008 at 20:57 UTC | |
by ikegami (Patriarch) on May 20, 2008 at 00:40 UTC | |
| |
by dragonchild (Archbishop) on May 20, 2008 at 00:08 UTC | |
|