Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Use method/function signatures with Perl

by Anonymous Monk
on Dec 06, 2004 at 17:13 UTC ( #412701=note: print w/ replies, xml ) Need Help??


in reply to Use method/function signatures with Perl

Let's not confuse the want of better parameter checking with getter/setter duplication. Yes, combining the two is (IMHO) bad form, but in general I write OO without getter/setters anyhow, since this is sort of exposing implementation details and it shouldn't be done that way most of the time.

Ruby gets along fine with duck typing. I'm really not concerned there, and I'm not sure perl should be either. I guess the thing is when something is method-oriented, you'll run across the equivalent runtime error a bit sooner, as with Perl you have a good chance of only getting something like "not a HASH at (xxxxxx)".

The advantage of duck typing is that if you suddenly decide that your FrogBucket needs to accept Weasels, all you need to do is make your Weasels know how to quack().


Comment on Re: Use method/function signatures with Perl
Re^2: Use method/function signatures with Perl
by Ovid (Cardinal) on Dec 08, 2004 at 01:07 UTC

    Actually, the better parameter checking is merely to enforce traditional multi-method dispatch. You have a great point about Ruby's duck typing. If you don't care about types, just don't use Sub::Signatures 'strict' mode and dispatch will be based on the number of arguments and type will be ignored.

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412701]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-09-02 17:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (25 votes), past polls