Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^6: How do I prototype a function with a varying number of arguments?

by eyepopslikeamosquito (Archbishop)
on Jul 30, 2011 at 07:22 UTC ( [id://917593]=note: print w/replies, xml ) Need Help??


in reply to Re^5: How do I prototype a function with a varying number of arguments?
in thread How do I prototype a function with a varying number of arguments?

I think maybe I'm seeing the point you maybe were trying to get me to see.....the $$ prototype isn't really a limitation
Perhaps the point is that the $$ prototype can be a (confusing) limitation. For example:
use strict; use warnings; sub Fred($$) { my $arg1 = shift; my $arg2 = shift; print "arg1='$arg1'\n"; print "arg2='$arg2'\n"; } my @two_elt_arr = ( 'abc', 'def' ); Fred(@two_elt_arr); # oops, compile error: "Not e +nough arguments" Fred($two_elt_arr[0], $two_elt_arr[1]); # this works
See Modern Perl, "The Problem with Prototypes", page 242:
Prototype coercions work in subtle ways, such as enforcing scalar context on incoming arguments ... (examples elided) ... Those aren't even the subtler kinds of confusion you can get from prototypes.

  • Comment on Re^6: How do I prototype a function with a varying number of arguments?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found