Closed p5pRT closed 20 years ago
If I declare (and or define) my function before I use it
sub func() { return 1; }
$returned = func(17);
print $returned;
Then I get a fatal error if the protptype doesn't match.
Too many arguments for main::func at foo.pl line 7\, near "17)" Execution of foo.pl aborted due to compilation errors.
However\, if the function is not declared until after the call
$returned = func(17);
print $returned;
sub func() { return 1; }
There is no error (fatal or otherwise).
This violates the Principle of Least Astonishment.
I could buy the argument that this is Difficult To Solve. I think it's a bug even so.
Nevertheless\, it would be useful at least if -w would warn about
Prototype declared too late in code
or something similar so that folks like me who put the functions at the end of
the script would have some warning (and folks who \
Migrated from rt.perl.org#963 (status was 'resolved')
Searchable as RT963$