Article View: net.lang.c++
Article #194Re: Re: Unintuitive semantics for initializing in for statements
From: peter
Date: Sat, 10 May 1986 12:33
Date: Sat, 10 May 1986 12:33
33 lines
1844 bytes
1844 bytes
> the "else" of a "for" would be skipped if the loop was exited by means
> of a "break" statement. Of course, once you allow "for"s to have "else"s,
> why deprive "while"s, and "do-while"s? This is not a tenable solution
> in C++, since it would break some existing C programs (unless "else"s bound
> to "if"s more strongly than they did to "for"s :-) Just a thought. Pros?
> Cons? Gut-level feelings of revulsion?
I like it, however the semantics of the statement don't quite gibe with
the syntax if you use it the way you describe. How about this equivalence?
New Syntax Equivalent Code (except for evaluations):
while(e) if(e)
s1 while(e)
else s1
s2 else
s2
for(i; e; i) i;
s1 if(e)
else for(; e; i)
s2 s1
else
s2
...and so on. Of course, this doesn't address the problem of the value of
the iteration variable. Personally, I prefer to be able to test the value
of that variable directly. Of course I usually make my iteration variables
registers anyway, since most of the code I write these days is real-time
stuff...
--
-- Peter da Silva
-- UUCP: ...!shell!{baylor,graffiti}!peter; MCI: PDASILVA; CIS: 70216,1076
Technical Details
Message-ID:
<640@baylor.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!harvard!husc6!panda!genrad!decvax!bellcore!ulysses!mhuxr!mhuxn!ihnp4!houxm!whuxl!whuxlm!akgua!gatech!drillsys!soma!bcm5000!baylor!peterReferences:
<17195@rochester.ARPA> <5334@alice.uUCp> <163@zaiaz32.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!harvard!husc6!panda!genrad!decvax!bellcore!ulysses!mhuxr!mhuxn!ihnp4!houxm!whuxl!whuxlm!akgua!gatech!drillsys!soma!bcm5000!baylor!peter From: peter@baylor.UUCP Newsgroups: net.lang.c++ Subject: Re: Re: Unintuitive semantics for initializing in for statements Message-ID: <640@baylor.UUCP> Date: Sat, 10-May-86 08:33:09 EDT Article-I.D.: baylor.640 Posted: Sat May 10 08:33:09 1986 Date-Received: Fri, 16-May-86 02:31:06 EDT References: <17195@rochester.ARPA> <5334@alice.uUCp> <163@zaiaz32.UUCP> Organization: The Power Elite, Houston, TX Lines: 33