Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!think!ima!haddock!karl From: karl@haddock Newsgroups: net.lang.c++ Subject: Re: for != while Message-ID: <165200003@haddock> Date: Thu, 18-Sep-86 20:24:00 EDT Article-I.D.: haddock.165200003 Posted: Thu Sep 18 20:24:00 1986 Date-Received: Sat, 20-Sep-86 21:03:50 EDT References: <1793@mmintl.UUCP> Lines: 31 Nf-ID: #R:mmintl.UUCP:1793:haddock:165200003:000:1374 Nf-From: haddock!karl Sep 18 20:24:00 1986 mmintl!franka (Frank Adams) writes: >In C++, one may instead write >main() { > char *foo = "outer"; > for (;; printf(foo),exit(0)) char *foo = "inner"; >} >which should, in fact, print "inner"[1]. I don't currently have accesss to >the C++ processor; does anyone know whether these two examples in fact work >correctly for it? >[1] Actually, my example may be an illegal multiple definition of foo. In >this case, try it with the "outer" declaration removed. Or just move the outer declaration to outside the function; then it should compile in any case. On a related note -- after I apologized for posting that blooper in the first place, I pointed out that the for-while equivalence SHOULD be written for (e1;e2;e3) s --> { e1; while (e2) { s e3; } } with the outer braces necessary to make "if (e0) for (e1;e2;e3) s" have the right semantics. Given this, it seems to me that in the code fragment for (int i=0; i