Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 7/7/83; site rlgvax.UUCP Path: utzoo!linus!decvax!harpo!floyd!clyde!ihnp4!zehntel!hplabs!hao!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang.c Subject: Re: the 'broken' statement Message-ID: <1272@rlgvax.UUCP> Date: Mon, 10-Oct-83 16:58:03 EDT Article-I.D.: rlgvax.1272 Posted: Mon Oct 10 16:58:03 1983 Date-Received: Wed, 12-Oct-83 23:58:19 EDT References: <301@ihuxa.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 47 I suspect the construct FIRST i IN something-that-generates-a-sequence-of-values SUCHTHAT condition DO found it ELSE not found END was supposed to be equivalent to for (first value; ;next value) { if (condition) goto found; } not found; goto join; found: found it; join: not to: for(first value; ;next value) { if (condition) { found it; break; /*stop loop when first value *is found such that 'condition' *is satisfied */ } else not found; } I.e., the "found it" and "not found" clauses are executed when the loop is finished; the first is executed if the loop terminated because the object was found, and the second is executed if the loop terminated because it ran out of values. It does require a bunch of "goto"s and is a bit of a pain to code (no claim is made here whether adding it to C would be a bigger or smaller pain). Guy Harris {seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy