[MERGE] Document code layout stuff
John Arbash Meinel
john at arbash-meinel.com
Thu Sep 6 15:57:49 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Harald Meland wrote:
> [Alexander Belchenko]
>
>> What about conditional statement?
>>
>> if (asdfghjkl != qwertyuio() or
>> mnbvcxzasdfgh == poiuytreweqlkjhgfgdfs()):
>> action
>>
>> Is right?
>
> The amount of indentation is correct, AFAICT, but I would have written
> the above as
>
> if (asdfghjkl != qwertyuio()
> or mnbvcxzasdfgh == poiuytreweqlkjhgfgdfs()):
> action
>
> i.e. with the "or" operator at the start of line two rather than at
> the end of line one, to make it easier to spot the difference between
> the condition's continuation line and the action.
>
> This practice already appears to be quite common in Bazaar code.
>
> PEP 8 doesn't appear to say anything about where to put logic
> operators in multi-line conditions like this; maybe it should be
> mentioned in HACKING.txt?
I use this form ('or' at the beginning of lines), so a lot of it is just the
habit of developers. :)
I thought one of the GNU style guidelines actually recommended:
if (x == 10 &&
y == 20)
Which I never agreed with, preferring:
if (x == 10
&& y == 20)
Especially when you get a lot of them.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG4BVsJdeBCYSNAAMRAv5HAKCP2fOonVUQ6U4i2PVYXh+aFwi9bACeLbm5
WStXHOpQf+Vcjj9UTXz91Ak=
=q2IP
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list