Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Re: Subroutine Bewilderment

by Joost (Canon)
on May 29, 2004 at 23:40 UTC ( [id://357528]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Subroutine Bewilderment
in thread Subroutine Bewilderment

Note that we don't run into problems until we start introducing prototypes, which generally people say to "stay away from", which is fine, but with caveats...
Well... that's what prototypes are meant for: breaking the rules, and that entails you're taking the risk of confusing the users of your library, the perl parser, or both.

You can only 'stay away' from something for so long, and then finally you want to become one of those mythical people who 'really really really know what they are doing'
I understand your concern, but I can only repeat the above paragraph. The phrase "enough rope to hang yourself" comes to mind.

Replies are listed 'Best First'.
Re: Re: Re: Re: Subroutine Bewilderment
by doom (Deacon) on May 31, 2004 at 07:00 UTC
    Joost wrote:
    Note that we don't run into problems until we start introducing prototypes, which generally people say to "stay away from", which is fine, but with caveats...
    Well... that's what prototypes are meant for: breaking the rules, and that entails you're taking the risk of confusing the users of your library, the perl parser, or both.
    I don't think this is a satisfactory summary of what prototypes are for. The way I would put it is that prototypes are included to let any programmer write something that behaves like one of the perl built-ins rather than a "normal" subroutine. They're there so that you can write things that work like
    $card = pop_random(@deck)
    that deals from the middle of the deck instead of the top the way pop would.

    As far as the main question is concerned, I can really only think of a couple of things to say, and they're pretty obvious. When there's always more than one way to do it, it's incumbant on the user of a subroutine to check the documentation, looking for examples of how to use it in the SYNOPSIS. And it's incumbant on the original programmer to document the code, and make sure there's a SYNOPSIS with decent examples in it.

    If by some strange unheard of quirk of misfortune you're working with an undocumented code base, there's always the source...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-03-29 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found