Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!floyd!clyde!ihnp4!inuxc!pur-ee!uiucdcs!uiuccsb!essick From: essick@uiuccsb.UUCP Newsgroups: net.lang.c Subject: Re: the 'broken' statement - (nf) Message-ID: <3219@uiucdcs.UUCP> Date: Thu, 13-Oct-83 23:35:30 EDT Article-I.D.: uiucdcs.3219 Posted: Thu Oct 13 23:35:30 1983 Date-Received: Sat, 15-Oct-83 06:25:17 EDT Lines: 32 #R:utzoo:-323200:uiuccsb:9000003:000:946 uiuccsb!essick Oct 13 13:34:00 1983 Seems to me that the easiest way to implement the "first i in list" construct in C is the following: for ( i=0;i < Limit; i++) /* check the candidates */ if ( condition ) break; if ( i == Limit ) /* or whatever it asumes */ { /* when it overruns the list */ not found; } else { found; /* and it is element "i" */ } If the collection of items to be checked is a linked list, change the appropriate for conditions and make the found/notfound test a comparison to NULL. How would you specify the list? Is it always an array? a linked list? a binary tree? a completely specified list of simple [== non array] variables? Have the compiler understand about all these data structures? Blech. The only case I can think where this might help is in PASCAL where you don't have a break statement; PASCAL would benefit more from adding a break statement than adding this construct. -- Ray Essick, University of Illinois