From owner-freebsd-hackers@FreeBSD.ORG Fri May 1 20:48:48 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F112106564A for ; Fri, 1 May 2009 20:48:48 +0000 (UTC) (envelope-from zbeeble@gmail.com) Received: from mail-ew0-f171.google.com (mail-ew0-f171.google.com [209.85.219.171]) by mx1.freebsd.org (Postfix) with ESMTP id 8A94E8FC1E for ; Fri, 1 May 2009 20:48:47 +0000 (UTC) (envelope-from zbeeble@gmail.com) Received: by ewy19 with SMTP id 19so2515144ewy.43 for ; Fri, 01 May 2009 13:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=8/aynW+rH3syutbaGitYDSMw0GTw5jC9DenY2kiE2F4=; b=NpKyTXmbnGokoH0VtThn2KZ1jryTzL7tXojX+8QO7asHNhnHNHb/5fxRzrnuq3lPXa C89fSeqSv3Kz96ltsCtpX+A9mujlbcn/9yIwrueHcFWSIfYk/cK3Sk0gHjgTiF9TS2Fl zthmFHia+nPmyW5+tQ16yMc0teEm8T5e1p2pk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=qDcuWITKdN5cB7w1xhZYRQHv4pci228SDxamB9uciTIoJh6A7RhblOc8IvnfnFKdHS uB3ntBJMSRi+OuusP2FBvwWwvK+DL5n9g/ZOSN5KPI2zfn+VZ4q5pHJEDvzuRqLQqWnI JatdSDm14K6y0EG9hxYRSN8v4mBti531zsDIc= MIME-Version: 1.0 Received: by 10.210.10.8 with SMTP id 8mr903815ebj.49.1241209445081; Fri, 01 May 2009 13:24:05 -0700 (PDT) In-Reply-To: <49FAB322.9030103@elischer.org> References: <49F4070C.2000108@gmx.de> <20090428114754.GB89235@server.vk2pj.dyndns.org> <20090430.090226.1569754707.imp@bsdimp.com> <49FA8D73.6040207@gmx.de> <49FAB322.9030103@elischer.org> Date: Fri, 1 May 2009 16:24:05 -0400 Message-ID: <5f67a8c40905011324s2ad5e02dy47c73ae950845b54@mail.gmail.com> From: Zaphod Beeblebrox To: Julian Elischer Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org, Christoph Mallon Subject: Re: C99: Suggestions for style(9) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2009 20:48:48 -0000 On Fri, May 1, 2009 at 4:30 AM, Julian Elischer wrote= : > As an old-fart I have found many cases where what I thought was > a silly style rule, turned out to save my work in some way. > > Christoph Mallon wrote: > > > >>> >>> struct foo *fp; >>> struct bar *bp; >>> >>> fp =3D get_foo(); >>> if (!fp) return; >>> bp =3D fp->bp; >>> >>> this can't easily be translated to the more natural: >>> >>> struct foo *fp =3D get_foo(); >>> struct bar *bp =3D fp->bp; >>> >> > Well more natural for you, but not necessarily for everyone, > and NOT the same as what is there now, as you noticed. > > > >>> since really you'd want to write: >>> >>> struct foo *fp =3D get_foo(); >>> if (!fp) return; >>> struct bar *bp =3D fp->bp; >>> >>> which isn't legal in 'C'. However, we have enough where this isn't >>> >> >> You're mistaken, this is perfectly legal C. See ISO/IEC 9899:1999 (E) >> =A76.8.2:1. In short: you can mix statements and declarations. >> > Sure, but it's still very bad: If I'm not mistaken, this would mean that "bp" would only be valid within the "if" clause --- which isn't very useful= .