in reply to Re^2: warnings and strict -- The 2 Best Ways You Can Improve Your Programming
in thread warnings and strict -- The 2 Best Ways You Can Improve Your Programming
But with prototypes, they aren't:sub ratio_change {...} my @args = ($start_value, $start_total, $new_value, $new_total); ratio_change @args; # Same result as: ratio_change $start_value, $start_total, $new_value, $new_total;
sub ratio_change ($$$$) {...} my @args = ($start_value, $start_total, $new_value, $new_total); ratio_change @args; # Eeks. Won't do what you think it does. ratio_change $start_value, $start_total, $new_value, $new_total;
I don't shy away totally from using prototypes, but the only types I use are:
that is, I purely use prototypes to tell the parser how to parse things. I don't use it for argument checking (which is the typical use for '$$$$' style prototypes) as that get annoying fast - due to '$''s side effect of creating scalar context.sub foo (); sub foo ($); sub foo (&@); sub foo (\@@); sub foo (\%@);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: warnings and strict -- The 2 Best Ways You Can Improve Your Programming
by liverpole (Monsignor) on Oct 05, 2005 at 14:06 UTC | |
by Perl Mouse (Chaplain) on Oct 05, 2005 at 14:12 UTC | |
by liverpole (Monsignor) on Oct 05, 2005 at 14:27 UTC |