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

Re: Re: Are prototypes evil?

by sauoq (Abbot)
on Sep 03, 2002 at 20:47 UTC ( #194893=note: print w/ replies, xml ) Need Help??


in reply to Re: Are prototypes evil?
in thread Are prototypes evil?

So, to do a hyper-add on two lists with that, "dmap { $a + $b } @foo, @bar". Without the prototype, that would have to have been written as the uglier "dmap sub { $a + $b }, \@foo, @bar"

If you wanted to use a literal list or the output of another sub as the second argument to dmap() as it is written in your node, you'd have to resort to dereferencing anonymous arrayrefs such as: @{[ your_sub_or_list_here ]} and that's just as ugly if not more so. The other choice would be to circumvent the "prototype" by calling it as &dmap( ... ) instead.

It might be "uglier" for some calls, but by writing it without the prototype, you encourage consistency which translates to cleaner code overall.

-sauoq
"My two cents aren't worth a dime.";


Comment on Re: Re: Are prototypes evil?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2014-09-18 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (123 votes), past polls