From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public From: emcmanus@gr.opengroup.org (�amonn McManus) Subject: Re: Mixing declarations and statements (Re: Porting (was ADA and Pascal etc)) Date: 1997/11/05 Message-ID: #1/1 X-Deja-AN: 288030791 References: <34557f2b.1934172@news.mindspring.com> <878495810snz@genesis.demon.co.uk> <63nlk6$h0e$1@darla.visi.com> Organization: Open Group Research Institute, Grenoble, France Newsgroups: comp.lang.ada,comp.lang.c Date: 1997-11-05T00:00:00+00:00 List-Id: seebs@plethora.net (Peter Seebach) writes: > So, what you might do is > switch (thing) { > int x; > case one: > ... > } > and, of course, you can't count on x being initialized, because you'll > be jumping in past the initializer. Right, I neglected to mention that possibility in my article. Of course it is legal in current C so the ability to mix declarations and statements gains you nothing here; I still maintain that switch statements are a bad example of where that is useful. I do think the new feature is handy in biggish functions that have several phases but are not big enough to justify splitting those phases out into separate functions; or where the initialisation of a declared variable requires work to have been done on previous variables that can't easily be squeezed into their declarations. , Eamonn http://www.gr.opengroup.org/~emcmanus "Je ne suis pas celle que vous croyez!" -- Dimitri from Paris