[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fixing indentation in our source files



Niels Thykier <niels@thykier.net> writes:

> So we are looking at a 4 space indentation for each basic block?

> if ($a) {
>     do_stuff();
> }

Yeah.

> How about "extended ifs"?

> if(<some very long condition> &&
>         <even more condition)
>     do_stuff();
> }

I'm agnostic on that.  8-space indents are often clearer, even if
inconsistent somewhat.

>  - and -

> do_stuff unless <some very long condition> &&
>     <even more condition>;

I would tend to write this as:

    do_stuff
        unless (<some very long condition>
                && <even more condition>);

since the parens make Emacs keep the indentation consistent, but I'm
agnostic on this too.  Although even better would be to find ways of
avoiding writing things like this, since I think they're inherently harder
to read compared to pulling the condition into a sub or assigning it to a
variable with a reasonable name.

> Are there other cases worth considering/debating?

There's oodles of stuff one can run into.

Just as random input (I'm definitely not advocating that we adopt this as
an official coding style), my personal Perl style is at:

    http://www.eyrie.org/~eagle/notes/style/perl.html

It's easy to spend way too much time discussing this sort of thing than
it's actually worth.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>


Reply to: