Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Are prototypes evil?

by BrowserUk (Pope)
on Sep 02, 2002 at 21:40 UTC ( #194640=note: print w/ replies, xml ) Need Help??


in reply to Are prototypes evil?

I guess the best answer is the very last part of the "Prototypes" section of perlman:perlsub which concludes with:

And the split gets called in scalar context so it starts scribbling on your @_ parameter list. Ouch!

Effectively, using prototypes throws away one of the nicest and most unique features of perl, namely the context sensitivity of the calling eviroment. Using them renders wantarray superfluous.



Well It's better than the Abottoire, but Yorkshire!


Comment on Re: Are prototypes evil?
Download Code
Re: Re: Are prototypes evil?
by Django (Pilgrim) on Sep 02, 2002 at 21:53 UTC

    I think you're mixing up two things:
    A ($) prototype would force scalar input to a sub, but that doesn't have any influence on the return context.
    Look at this:

    sub Input ($) { wantarray ? split /,/ : $_; } my @List = Input $Source;

    ~Django
    "Why don't we ever challenge the spherical earth theory?"

      Your right! I was talking twaddle!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2014-08-31 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls