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

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
Replies are listed 'Best First'.
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;

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

      Your right! I was talking twaddle!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2015-10-07 03:58 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls