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: nasser@apldbio.com Subject: Re: Why C++ is successful Date: 1998/08/13 Message-ID: <6r0m27$r3j@drn.newsguy.com>#1/1 X-Deja-AN: 381025600 References: <6qfhri$gs7$1@nnrp1.dejanews.com> <35cb8058.645630787@news.ne.mediaone.net> <902934874.2099.0.nnrp-10.c246a717@news.demon.co.uk> Organization: Newsguy News Service [http://www.newsguy.com] Newsgroups: comp.lang.ada Date: 1998-08-13T00:00:00+00:00 List-Id: In article , dewar@merv.cs.nyu.edu says... >The two obvious uses vfor gotos in Ada are > >1) to get a loop "continue" mechanism > >2) to write finite state machines encoding the state into the PC. what about a common exit for a function? as we all know (offcourse :) that a function should have one common exit. multiple retruns from inside a function can make the function harder to maintain. sometime it is easier to go to a common_exit label at the bottom of the function, where some common cleanup can be done if needed, rather than use a nested if then else to try to carry the logic through all the way down. example: if status /= good then goto common_exit; end if; status = do_soemthing; if status /= good then goto common_exit; end if; status = do_another_thing etc.. <> return status; -- or log error message if status not good..etc.. without a goto, one has to do: example: if status = good then status = do_somtehing; if status = good then status = do_another_thing else etc.. -- error end if; else .. -- error end if; Nasser