Don't ask to ask, just ask | |
PerlMonks |
PBP: Code Layoutby saberworks (Curate) |
on Oct 19, 2005 at 21:15 UTC ( [id://501433]=perlquestion: print w/replies, xml ) | Need Help?? |
saberworks has asked for the wisdom of the Perl Monks concerning the following question:
Just got my copy of Perl Best Practices and I'm trying to figure out the author's "rule" for subroutine parameter passing. If it's spelled out somewhere, I can't find it, so please point me at the correct page and I'll leave you alone. If not, here is the source of my confusion. On page 12 there is a bolded code example: my @candidates = get_candidates($marker); Which leads me to believe he doesn't want spaces after or before the parens. For example, he likes the above better than: my @candidates = get_candidates( $marker ); However, on page 13, there are lines like this: So the "rule" appears to be: "If it's a built-in, don't add spaces, except if there's only one argument, then do add spaces. If it's user-defined, don't add spaces, even if there is only one argument." Except, then I found one on page 29 that was even worse: add_step( \@steps, $next_step, $elapsed_time); I also find it disconcerting that the author advocates putting spaces for "complex" hash keys, like $foo = $var{ $names{$i} }, but not for code blocks in things like grep and map: grep {defined $_} @something; (and actually on page 17 I see map { sqrt $_ } @results; so maybe this is just an accidental inconsistency). So maybe I'm being picky, but my company is now trying to identify a coding standard for all our programmers to use, and at the beginning of the chapter I was hoping I could just point to this and say, "we should use this, it's clearly documented, there's reasoning behind each recommendation, and other good perl programmers coming on board will have a high liklihood of being previously exposed to it." Am I looking at typos which will be fixed in the next version of the book or is this issue something that's generally not explicitly defined in most coding standards?
Back to
Seekers of Perl Wisdom
|
|