in reply to Re^2: What's the better Perl style? Define parameters or not?
in thread What's the better Perl style? Define parameters or not?

Yes, and prototypes are the same as that. They're useful in narrow circumstances where you know that you're not violating the principles that make them evil. And you can consider the pronouns in the previous sentence to be talking about either goto in C/C++ or prototypes in Perl. Personally, I've only used prototypes when trying to duplicate map or grep-like syntax (first parameter is a code block), but, even then, I usually avoid them. I'm not sure you could get try { BLOCK } catch { BLOCK } kind of syntax without prototypes, but I wouldn't want those new to perl to be writing that code as they probably wouldn't understand the details of prototypes (or much else around the desired syntax).

Replies are listed 'Best First'.
Re^4: What's the better Perl style? Define parameters or not?
by JavaFan (Canon) on Jan 05, 2010 at 15:46 UTC
    I'm not sure you could get try { BLOCK } catch { BLOCK } kind of syntax without prototypes,
    You can't1. You'd have to write it as:
    try sub {BLOCK}, catch sub {BLOCK}
    I wouldn't want those new to perl to be writing that code as they probably wouldn't understand the details of prototypes
    That's quite an elitist remark which I do not agree with.

    1 Well, you can if you leave Perlland, and enter the world of source filters. Or perhaps the world Devel::Declare or some other universe that messes with internals.