From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public From: adam@irvine.com Subject: Re: Software landmines (was: Why C++ is successful) Date: 1998/08/19 Message-ID: <6rf1f2$tqn$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 382686633 References: <6rd27s$ffi$1@nnrp1.dejanews.com> Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Aug 19 17:19:30 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/3.0 (X11; I; Linux 2.0.18 i586) Date: 1998-08-19T00:00:00+00:00 List-Id: In article , stt@houdini.camb.inmet.com (Tucker Taft) wrote: > adam@irvine.com wrote: > : ... > : Anyway, here's my main question: Is it desirable to expand the syntax of > : "exit" to cover cases like this? I think it might be nice. I'm thinking that > : code like this could look something like: > > : block_to_do_stuff: > : begin > : blah-blah-blah; > : exit block_to_do_stuff when error-condition-1; > : keep-going; > : exit block_to_do_stuff when error-condition-2; > : still-keep-going; > : exit block_to_do_stuff when error-condition-3; > : everythings-still-fine-keep-going; > : etc. > : end block_to_do_stuff; > > : I think one of the Ada 9X proposals actually had a feature like this, but > : unfortunately it also changed the semantics of "exit" in a way that would > : change the meanings of a lot of Ada 83 code. Probably, that's why it was > : dropped from the final Ada 95 definition. > > The Ada 9x proposal was "upward consistent" in that it didn't change the > meaning of any existing programs to a new legal meaning, but it did make > some of them illegal (those that involved exits from blocks nested in loops, > I believe). Not just blocks--I think compound statements were involved. If my recollection is correct, it would have made the following code illegal: for I in Arr'Range loop if Arr (I) = Search_Value then Found_Index := I; exit; <==== illegal according to 9X draft end if; end loop; But I do remember now that this would have been illegal and not legal with a different meaning. As I recall, I did a grep through the code of my main project for "exit;" (which would have always been illegal under this proposal---the proposed syntax did not allow for "exit" all by itself) and found it occurred about a hundred times. I thought this was pretty obnoxious. > If there were a solution that treated loops and blocks symmetrically, > that would be nice. But a proposal that only allows exiting from > unnamed loops, while disallowing exiting from unnamed blocks, is > a kludge. I would prefer something which allowed an unnamed "exit" to be > legal only if there were exactly one block or loop enclosing the point. Actually, this would make a lot of sense to me. I think I tend to do this anyway when two loops are nested, but I'd have to look through my code to make sure. I'd support a proposal like this; the amount of previously legal code that would be made illegal would be IMHO *much* less than the dropped 9X proposal did. I also agree that this is a minor problem. I'm willing to add this case to the short list of situations where "goto" is appropriate. Now all I have to do is go against all my training and allow that 4-letter word into my code. Easier said than done. :) -- Adam -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum