Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!drutx!houxe!hogpc!houti!ariel!vax135!cornell!uw-beaver!tektronix!hplabs!hpda!fortune!amd!decwrl!decvax!cca!ima!ism780b!jim From: jim@ism780b.UUCP Newsgroups: net.lang.c Subject: Re: K&R App A, par. 8 & 8.2, on Declarat - (nf) Message-ID: <8@ism780b.UUCP> Date: Wed, 1-Aug-84 00:26:15 EDT Article-I.D.: ism780b.8 Posted: Wed Aug 1 00:26:15 1984 Date-Received: Sun, 22-Jul-84 03:02:47 EDT Lines: 25 #R:log-hb:-18000:ism780b:25500002:000:686 ism780b!jim Jul 13 19:35:00 1984 > I agree that "a = 1;" should be a valid global declaration, but see > nothing wrong with it as a local one. The statements "int a=1;" > "int a; a = 1;" and "a = 1;" should all produce equivalent code! > This is because of the way C handles initialization of automatic > local variables. The only problem I can see is in letting the > compiler tell where the declarations end and the statements begin. > If you allow this as a valid declaration, that's not a problem. int a = 2; main() { a = 1; x(); } x() { printf("%d\n", a); } will print "2" if "a = 1" is a declaration, "1" if it is an assignment (current, expected, behavior). -- Jim Balter, INTERACTIVE Systems (ima!jim)