Re: perlstyle - Unclear wording
by radiantmatrix (Parson) on Nov 18, 2005 at 14:34 UTC
|
Funny, I've always interpreted that particular advice in the context of nested parens. The last paren that has a match on the current line should get a space, but I think it only applies with nested parens. I.e.:
#do this:
if (($a+b) eq ($c-$d) ) { }
#instead of:
if (($a+b) eq ($c-d)) { }
#but I do:
if ( ($a+b) eq ($c-$d) ) { }
It never even occured to me that it could mean something different.
| [reply] [d/l] |
Re: perlstyle - Unclear wording
by jonix (Friar) on Nov 18, 2005 at 15:36 UTC
|
While the respective style guide is part of Programming Perl (3rd Edition, july 2000) in a way -
some wordings are different, not as brief and more concise - the ambiguous advice in question does not seem to be part of it. The relevant chapter is 24 'Common Practices', 'Programming with Style' IMHO.
I am wondering whether it was omitted on purpose, or was it added to the pod later on?
Regards,
jonix | [reply] |
Re: perlstyle - Unclear wording
by Aristotle (Chancellor) on Nov 18, 2005 at 13:59 UTC
|
I wouldn’t say that is unclear, I’d say it makes no sense. “Unclear” would mean there are multiple possible interpretations – in this case, though, I can’t find even one. How does a parenthesis “match on current line”?
Makeshifts last the longest.
| [reply] |
|
How does a parenthesis “match on current line”?
Like-a-so:
( ($a eq "foo") && ($b eq "bar") )
In each case, the close parens "matches" it's open parens (the converse is also true). So, if it "matches on current line", the open and close are on the same line.
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
| [reply] [d/l] |
|
( ( $a || $b ) && ( $c || $d ) )
And it looks weirdly out of place in code of someone who doesn’t, as in:
(($a || $b) && ($c || $d) )
Makeshifts last the longest. | [reply] [d/l] [select] |
|
Re: perlstyle - Unclear wording
by eric256 (Parson) on Nov 18, 2005 at 13:51 UTC
|
What is the other option? I can't think of anything else that matches that statment so it seems clear.
___________
Eric Hodges
$_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9';
s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;
| [reply] |
|
if ( ($foo == 1)
and ($bar == 1) ){
# ^ space after last matching parens
Also, in plain statements, it doesn't make much sense:
(caller) [0]
# ^ space after last matching parens?
| [reply] [d/l] [select] |
|
Yes, it would be clearer if it said something like "Space
between two right parens when the first matches a left paren on the current line and the second matches a left paren on a previous line."
| [reply] |
|
if (($a1 == $a2) &&
($a3 == $a4) &&
(($a5 == $a6) || ($a7 == $a8))
)
{
}
This way of breaking makes it clear (at least to me) that those lines are at the same level. | [reply] [d/l] |
|
|
|
| [reply] |