in reply to Prototyping Subs: Good,Bad,Indifferent

Have you read FMTYEWTK about Prototypes by Tom Christiansen yet? It's the reference for everything that's wrong/annoying/misunderstood about Perl's prototypes.

In other programming experience I had developed the opinion that protypes were a good thing as they provide usage enforcement
Prototypes in Perl are not analagous to prototypes in other languages. Calling them "prototypes" is a bit of a misnomer. But Tom Christiansen describes this better than I can.

I know many monks, myself included, only use prototypes to get subs to look like builtins, especially passing a bare block as the first argument (as in grep { ... }) or an array ref (as in splice @arr). They're ok occasionally for this kind of syntactic sugar, but they're not as useful as you'd think for actually enforcing parameters. As I said, read that article if you haven't read it yet, otherwise read it again ;)

blokhead

  • Comment on Re: Prototyping Subs: Good,Bad,Indifferent

Replies are listed 'Best First'.
Re: Re: Prototyping Subs: Good,Bad,Indifferent
by knexus (Hermit) on Aug 31, 2003 at 20:11 UTC
    That article really helps.
    I certainly was NOT accomplishing what I thought.

    Thanks