A preference in the style guide

A

Arndt Jonasson

I've been reading the style guide (perldoc perlstyle), and I have
trouble understanding one of the short preferences listed in the
beginning:

"Space after last parenthesis matching on current line."

Can someone give simple examples where this preference is
followed, and not followed, respectively?

(I also had problems with "uncuddled elses.", but dejanews solved that
for me - "cuddled" means being surrounded by braces on the same line.)
 
A

Anno Siegel

Arndt Jonasson said:
I've been reading the style guide (perldoc perlstyle), and I have
trouble understanding one of the short preferences listed in the
beginning:

"Space after last parenthesis matching on current line."

Can someone give simple examples where this preference is
followed, and not followed, respectively?

This follows the rule:

foo(
bar( baz( 3.141)) );

There's a space before the last ")" because the matching opening "("
isn't on the same line.

Anno
 
B

Ben Morrow

Quoth (e-mail address removed)-berlin.de (Anno Siegel):
This follows the rule:

foo(
bar( baz( 3.141)) );

There's a space before the last ")" because the matching opening "("
isn't on the same line.

FWIW I've recently taken to invariably writing the above as

foo(
bar( baz(3.141))
);

with the closing ) lined up as though it was a brace: it uses an extra
line, but I find it much clearer. (to generalize, I would write a
compilcated if as

if (
foo && bar && baz
) {
...
}

..)

Ben
 
A

Anno Siegel

Ben Morrow said:
Quoth (e-mail address removed)-berlin.de (Anno Siegel):

FWIW I've recently taken to invariably writing the above as

foo(
bar( baz(3.141))
);

That's what I do too. In fact, in such cases I would introduce parentheses
in a call I would write without if it fit on one line, so

map <short_expression>, <short_list>;

becomes

map(
<long_expression>,
<long_list>,
);

If the function has more than one argument, I add commas after all of
them, including the last one.

I'm not entirely consistent with this style, however.

map <long_expression>,
<long_list>;

is still an alternative if <long_expression> and <long_list> each fit on
one line. If they don't, it's definitely the parenthesized form.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top