home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.arch:10455 comp.lang.misc:3522
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!doc.ic.ac.uk!uknet!yorkohm!minster!mjl-b
- From: mjl-b@minster.york.ac.uk
- Newsgroups: comp.arch,comp.lang.misc
- Subject: Re: CLU break and continue (Was: Re: A challenge to the anti-goto)
- Message-ID: <721054332.26680@minster.york.ac.uk>
- Date: 6 Nov 92 12:52:14 GMT
- References: <1cvoctINNmhs@agate.berkeley.edu> <PSM.92Nov3165530@soma.sics.se> <1992Nov3.165005.18037@midway.uchicago.edu> <184123@pyramid.pyramid.com>
- Reply-To: mjl-b@minster.york.ac.uk (Mathew Lodge)
- Organization: Department of Computer Science, University of York, England
- Lines: 63
-
- In article <184123@pyramid.pyramid.com> moliver@pyramid.com (Mike Oliver) writes:
- >In article <1992Nov3.165005.18037@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
- >>It should be noted that Ada and CLU have named loops and named breaks.
- >
- >I can't comment on Ada, but `break' in CLU (at least the version
- >described in Liskov and Guttag's 1986 "Abstraction and Specification in
- >Program Development") only has the ordinary single-level behaviour,
- >which lets you escape from the smallest enclosing loop.
-
- In Ada you can escape to any level using a named loop. For example:
-
- OUTER_LOOP: -- Named outer loop
- loop
- loop
- loop
- -- some code
- exit OUTER_LOOP; -- exit the outer loop
- end loop;
- -- ...
- end loop;
- -- ...
- end loop;
-
- >You're probably thinking of the `exit'/`except' mechanism, which allows
- >you to escape from multiple loops (or from within a `proc', with the
- >`signal' statement) by raising a condition which transfers control to
- >the nearest enclosing handler for that condition.
-
- This sounds a lot like the Ada exception mechanism. Briefly, when an
- exception is raised, the run-time starts looking for a handler for that
- particular exception. If there isn't one for that exception in the current
- block, the call stack is wound back until one is found, or the top-level
- subprogram is reached (when the program stops).
-
- It gets to be more complicated than this, particularly if you use tasks.
-
- >> Named continues, to use C terminology, are an obvious corrollary,
- >>but I don't believe that either Ada or CLU implements them (or even normal
- >>continues, for that matter.)
- >
- >CLU (again, the 1986 version) has the normal `continue', which
- >terminates execution of the smallest enclosing loop and begins the next
- >cycle, if one is required.
-
- This sounds like normal use of the Ada exit statement, which exits the
- enclosing loop.
-
- >BTW, anti-goto purists will be happy to learn that CLU doesn't have a
- >`goto' statement.
-
- Ada does, but the labels are surrounded by << and >>, which makes them very
- obvious during code review :-)
-
- >Cheers, Mike.
- >
- >moliver@pyramid.com
- >{allegra,decwrl,hplabs,munnari,sun,utai,uunet}!pyramid!moliver
-
- Mat
-
- | Mathew Lodge | "I don't care how many times they go |
- | mjl-b@minster.york.ac.uk | up-tiddly-up-up. They're still gits." |
- | Langwith College, Uni of York, UK | -- Blackadder Goes Forth |
-