Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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;

    "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 making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2014-09-18 16:31 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (118 votes), past polls