Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Are prototypes evil?

by atcroft (Monsignor)
on Sep 02, 2002 at 21:30 UTC ( #194639=note: print w/ replies, xml ) Need Help??


in reply to Are prototypes evil?

I have only started to work with prototypes somewhat myself, but my basic opinion (unless someone instructs me otherwise) is that they are not evil. While I can't recall for sure if they cause the engine to check to make sure the number and types of parameters passed are good, they do at least provide a convenient way to document the types and order of values to be passed, which at least would seem to me to help when someone is looking at a module written using them.

I look forward to the comments of others, though, on how they apply them, how effective they have been as a tool for others, or reasons to avoid them.


Comment on Re: Are prototypes evil?
Re: Re: Are prototypes evil?
by sauoq (Abbot) on Sep 03, 2002 at 21:22 UTC
    they do at least provide a convenient way to document the types and order of values to be passed, which at least would seem to me to help when someone is looking at a module written using them.

    Please no, No, NO, NO, NO! Say it ain't so! Comments are a convenient way to document the types and order of subroutine parameters; prototypes most certainly are not. That is arguably true in just about any language. In Perl, it is doubly so because using prototypes in places where they aren't needed creates an enormous maintenance hassle.

    I strongly encourage you to read Tom Christiansen's Prototypes in Perl which greenFox also mentioned in his reply above. You might be surprised to see how much trouble "prototypes" can get you into.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-08-30 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls