Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 May 2009 16:24:05 -0400
From:      Zaphod Beeblebrox <zbeeble@gmail.com>
To:        Julian Elischer <julian@elischer.org>
Cc:        freebsd-hackers@freebsd.org, Christoph Mallon <christoph.mallon@gmx.de>
Subject:   Re: C99: Suggestions for style(9)
Message-ID:  <5f67a8c40905011324s2ad5e02dy47c73ae950845b54@mail.gmail.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 1, 2009 at 4:30 AM, Julian Elischer <julian@elischer.org> 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=
.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5f67a8c40905011324s2ad5e02dy47c73ae950845b54>