Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Use method/function signatures with Perl

by ihb (Deacon)
on Dec 08, 2004 at 15:22 UTC ( #413223=note: print w/replies, xml ) Need Help??


in reply to Re: Use method/function signatures with Perl
in thread Use method/function signatures with Perl

For instance passing more args to a subroutine than it needs should IMO not be viewed as a bug. Its behaviour that many a perl programmer would consider completely normal.

We've touched this discussion before (Re: Re: Re: Context aware functions - best practices?). I do not agree. There is no concensus on what will happen with the extra arguments. I'm a firm believer of that documentation is what decides what should be considered a bug or not. If the documentation says a subroutine takes three arguments then I read that as the subroutine should be given three arguments. I don't read it as the subroutine should be given minimum three arguments.

If everyone would live by "it's OK to pass too many arguments" then there would be a lot of unnecessary incompatible updates (i.e. when the module author adds an argument to the subroutine interface). If everyone would live by "it's not OK to pass too many arguments" then module authors wouldn't have to worry about extending the subroutine interfaces and the number of incompatible updates would be reduced.

Assuming that passing too many arguments is silently ignored is to assume things about the implementation, and assuming things about the implementation is by general concensus evil.

Just because it works now doesn't mean it'll work tomorrow--unless documented to do so.

ihb

See perltoc if you don't know which perldoc to read!
Read argumentation in its context!

  • Comment on Re^2: Use method/function signatures with Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://413223]
help
Chatterbox?
[choroba]: pm-cb-g now shows the number of unread messages, commit on its way to github
[Tux]: choroba any plans for highlight patterns?
[choroba]: Tux feel free to submit a pull request :-)
[choroba]: I like the idea, but currently I only have time for small changes
[choroba]: but it should be a bit better in two weeks
[Tux]: time also lacks on this side to do more than tiny changes
[Tux]: running on a just pull'd pm-cb-g
[choroba]: :-)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (16)
As of 2017-09-20 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (237 votes). Check out past polls.

    Notices?