On Feb 28, 2004, at 7:05 PM, Andrew Gaffney wrote:

I'm getting conflicting advice between your post and another post to this thread. Maybe if I post my code, you can recommend the best way for me to setup my functions and the calls to them (and whether to prototype them). This code will be for an Apache 1.3.x/mod_perl 1.x/Mason website.

Yes, you've hit on a holy war among us Perl programmers. A lot of us feel strongly about prototypes, one way or another.


Perl's prototypes are a little flimsy at times. It's already been shown that just adding an ampersand to the call bypasses them, which would completely change your subroutine if references are involved, wouldn't it? Perl's method invocation system also bypasses them. For reasons like this (plus others), some of us try to avoid them. Of course, you shouldn't be putting that ampersand on the calls and we're not talking about methods here, so they should be safe.

Prototype's solve your problem and they're in Perl, so you can use them. We won't come to your workplace and take your computer away if you do, no matter how much Joseph wants to :D. If you do us them, just be aware that you can't always use them. There are situations where they will fail you. No big deal, it doesn't look like this is one of them.

If you don't/can't use them, you can of course always just pass the references manually. Something like:

subroutine_call($something, $something_else, [EMAIL PROTECTED], [EMAIL PROTECTED]);

That works fine and arguably shows what's going on a little better. Of course, you'll need to document this for the users of your code. Then again, you'll probably need to document that they don't have to do this, if you go the prototype's route. No escaping documentation, shucks.

The Moral: Both will work for you. Prototypes should be fine here. You can get by without them. Relax and use whatever feels right to you and your users. There is no right or wrong answer, if it runs. ;)

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to