Date: Wed, 27 Jan 1999 23:28:20 -0800 (PST) From: Matthew Dillon <dillon@apollo.backplane.com> To: Julian Elischer <julian@whistle.com> Cc: John Birrell <jb@cimlogic.com.au>, John Polstra <jdp@polstra.com>, bde@zeta.org.au, current@FreeBSD.ORG Subject: Re: btokup().. STYLE(9) Message-ID: <199901280728.XAA98161@apollo.backplane.com> References: <Pine.BSF.4.05.9901272302460.304-100000@s204m82.isp.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
:I think that style(9) should be modified to include :"Parenthesis may be used to improve the readbility of complex :expressions even if not strictly required." :instead of the stupid phrase presently there. :also: :"Braces around code blocks should be allowable even when not strictly :needed, for the purpose of readbility." : :The aim is to produce readble maintainable code, not to save bytes in :sourcecode! : :julian I agree completely. I've already gotten into the habit of added braces when conditonal expressions exceed one line, even though there may be only one statement. Otherwise the code is just too unreadable. if (expression) single_line_stmt; else single_line_stmt; if (some really complex expression) { single_line_stmt; } else { single_line_stmt; } if (expression) { single_line_stmt; } else { multi_line_stmt; multi_line_stmt; } if (expression) { multi_line_stmt; multi_line_stmt; } else { single_line_stmt; } All too often I see this: if (expression) { multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; multi_line_stmt; } else single_line_stmt; some other code here Or here. while (some really complex expression that takes a bunch of room) { single_line_stmt; } or while (some really complex expression that takes a bunch of room ) { single_line_stmt; } And I'll tell you, it just isn't readable, especially when you get into while()'s and do's and such with HUGE expressions and single-line bodies. If any part of the if () needs braces, I put the other part in braces as well. It would be nice if that were formalized. The issue with where to put the ') {' is a harder one to formalize... Probably half the people like it one way and half the people like it the other. IMHO. -Matt Matthew Dillon <dillon@backplane.com> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901280728.XAA98161>