Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: perltidy IF continuation indentation

by jaa (Friar)
on Oct 04, 2005 at 15:26 UTC ( #497283=note: print w/replies, xml ) Need Help??

in reply to Re: perltidy IF continuation indentation
in thread perltidy IF continuation indentation

Interesting observation!

I have set my perltidy options to the ones in Damian Conway's 'Perl Best Practices', and with these, adding the brackets makes no difference.

A bit of experimentation shows that this is because I have -i=2 and -ci=2. I have both the indent and continuation-indent settings set to the same value.

Without brackets, perltidy simple inserts a series of continuation-indents.

Add the brackets, and perltidy inserts a continuation-indent in front of the IF and then, recognising the presence of a container (the brackets) adds full indents as it wraps the container content.

The observation is much appreciated, as it has lead me to a better understanding of perltidy, but sadly doesn't really help. :(

Is anyone else going to use the PBP style? Do you just live with the ugliness of continuation-indent IFs?



  • Comment on Re^2: perltidy IF continuation indentation

Replies are listed 'Best First'.
Re^3: perltidy IF continuation indentation
by sauoq (Abbot) on Oct 04, 2005 at 15:40 UTC
    Is anyone else going to use the PBP style?

    Not if it makes my code look like that! ;-)

    I might be able to live with continuation-indent set to 1 instead of 2 though. As shown below, the perltidy documentation suggests that it should be no greater than that if -i=2.

    When default values are not used, it is suggested that the value n given with -ci=n be no more than about one-half of the number of spaces assigned to a full indentation level on the -i=n command.

    "My two cents aren't worth a dime.";

      Yes - I have seen the man page for -i and -ci. Having used the perlstyle guidelines for a few years, we are finding it an adjustment (we miss our cuddled elses!) :) but it does seem to have a certain internal consistency. One thing we do really like is the new cascading trinary operator layout. We used to just use whatever seemed right at the time.

      Which specific part of PBP style don't you like - and for what reason?



        Which specific part of PBP style don't you like - and for what reason?

        I don't own the book (nor do I expect to buy it.) I thumbed through it, and I just don't think it would be very helpful to me. Some of it I agree with and follow anyway, and some of it I just wouldn't. As for style in particular, well, here's my .perltidyrc:

        -ce -nsfs -isbc -olc

        Update: So... I'm curious... are people downvoting this node (currently +0 -3) simply because I refuse to idolize PBP and its illustrious author? Oh well. Sorry, but the more I think about it, the more convinced I become that if you're going to write "best practices" for a whole language, you better be pretty general and leave style issues alone altogether. Which practices are best usually depends on context. I suppose PBP is fine if you are just dropping sheaves of code from the top of your ivory tower though. Besides, a name like Perl Pretty Good Practices In Many Situations wouldn't have been nearly so catchy.

        "My two cents aren't worth a dime.";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://497283]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-01-21 01:40 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.