From owner-freebsd-questions Wed Mar 28 11:27:55 2001 Delivered-To: freebsd-questions@freebsd.org Received: from q.closedsrc.org (ip233.gte15.rb1.bel.nwlink.com [209.20.244.233]) by hub.freebsd.org (Postfix) with ESMTP id E44BE37B719 for ; Wed, 28 Mar 2001 11:27:52 -0800 (PST) (envelope-from lplist@closedsrc.org) Received: by q.closedsrc.org (Postfix, from userid 1003) id 2C40955407; Wed, 28 Mar 2001 11:18:02 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by q.closedsrc.org (Postfix) with ESMTP id 1C29451610; Wed, 28 Mar 2001 11:18:02 -0800 (PST) Date: Wed, 28 Mar 2001 11:18:02 -0800 (PST) From: Linh Pham To: j mckitrick Cc: Subject: Re: multiple C assignments in one statement In-Reply-To: <20010328201830.A76580@dogma.freebsd-uk.eu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2001-03-28, j mckitrick scribbled: # In the source code for the shortest DVD decoder to date, I saw statements # with multiple assignments (not declarations) all separated by commas. Does # this have any advantage, other than allowing a bunch of assignments to be # grouped in one statement without the need for braces? Statements are set apart by semi-colons in C/C++ rather than commas. The two blocks of code are the same: int a, b, c; a = 0; b = 3; c = a + b; [is the same as] int a, b, c; a = 0; b = 3; c = a + b; For readability, it's best not to cram multiple statements onto one line. If you want really compact code, then you can not only cram multiple statements together (again, separated by semi-colons) but also use obfuscated methods of doing the same thing as other functions. Braces are normally used to separate code from another chunks of code, like breaking code blocks into functions, etc. -- Linh Pham [lplist@closedsrc.org] // 404b - Brain not found To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message