From owner-freebsd-current Wed Jan 27 23:28:27 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA29759 for freebsd-current-outgoing; Wed, 27 Jan 1999 23:28:27 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from apollo.backplane.com (apollo.backplane.com [209.157.86.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA29748 for ; Wed, 27 Jan 1999 23:28:24 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.2/8.9.1) id XAA98161; Wed, 27 Jan 1999 23:28:20 -0800 (PST) (envelope-from dillon) Date: Wed, 27 Jan 1999 23:28:20 -0800 (PST) From: Matthew Dillon Message-Id: <199901280728.XAA98161@apollo.backplane.com> To: Julian Elischer Cc: John Birrell , John Polstra , bde@zeta.org.au, current@FreeBSD.ORG Subject: Re: btokup().. STYLE(9) References: Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message