Re: CodingGuidelines Perl amendment

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

 



Ted Zlatanov <tzz@xxxxxxxxxxxx> writes:

>  - As in C (see above), we avoid using braces unnecessarily (but Perl
>    forces braces around if/unless/else/foreach blocks, so this is not
>    always possible).

Is it ever (as opposed to "not always") possible to omit braces?

It sounds as if we encourage the use of statement modifiers, which
certainly is not what I want to see.

You probably would want to mention that opening braces for
"if/else/elsif" do not sit on their own line, and closing braces for
them will be followed the next "else/elseif" on the same line
instead, but that is part of "most of the C guidelines above apply"
so it may be redundant.

>  - Don't abuse statement modifiers (unless $youmust).

It does not make a useful guidance to leave $youmust part
unspecified.

Incidentally, your sentence is a good example of where use of
statement modifiers is appropriate: $youmust is rarely true.

In general:

	... do something ...
	do_this() unless (condition);
        ... do something else ...

is easier to follow the flow of the logic than

	... do something ...
	unless (condition) {
		do_this();
	}
        ... do something else ...

*only* when condition is extremely rare, iow, when do_this() is
expected to be almost always called.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]