Path: utzoo!mnetor!uunet!mcvax!ukc!its63b!aiva!ken From: ken@aiva.ed.ac.uk (Ken Johnson) Newsgroups: comp.lang.misc Subject: Re: Loops Message-ID: <341@aiva.ed.ac.uk> Date: 11 Apr 88 09:31:19 GMT References: <2827@enea.se> <1557@pasteur.Berkeley.Edu> <2773@mmintl.UUCP> <270@bby-bc.UUCP> <4266@ihlpf.ATT.COM> Reply-To: ken@uk.ac.ed.aiva (Ken Johnson,E32 SB x212E) Followup-To: comp.lang.misc Organization: Dept. of AI, Univ. of Edinburgh, UK Lines: 37 Summary: catch, throw How to allow breaking out of arbitrary loops, which you might otherwise have to do like this: >> done := false; >> while not done do begin >> do_some; >> done := done | done_now; >> if not done then begin >> do_some_more; >> done := done | done_already; >> end; >> else do_even_more; >> end; In some recent versions of Logo, and also in Lisp, you have the `throw/catch' construct, which I think looks a lot better: to a_program catch 'foo [ forever [ repeated_bit if [ throw 'foo ] other_repeated_bit ] ] last_bit When the `throw 'foo' is executed, execution resumes at `last_bit'. Catches may be nested. -- ------------------------------------------------------------------------------ From Ken Johnson, AI Applications Institute, The University, EDINBURGH Phone 031-225 4464 ext 212 Email k.johnson@ed.ac.uk