🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #37

Re: A challenge to the anti-goto

#37
From: Herman Rubin
Date: Wed, 04 Nov 1992 12:36
43 lines
2915 bytes
In article <BEVAN.92Nov3211454@hippo.cs.man.ac.uk> bevan@cs.man.ac.uk (Stephen J Bevan) writes:
>In article <1992Nov3.165005.18037@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
>   >   If we've known about this problem for twenty years, why don't we
>   >   have more powerful `break' instructions in our existing languages??

>   >Code the inner loops as a function, and use 'return' as your
>   >powerful 'break'. 

>   Well, no.  The idea is to be able to break out of multiple loops.  Making
>   functions out of your inner loops does nothing to help this.  You would have
>   to use setjmp/longjmp, with all the hideousness that entails.  

>   It should be noted that Ada and CLU have named loops and named breaks.  They
>   are indeed quite nice for many control flow problems.

>You could always use a variant of the function approach and have
>explicit continuations i.e. don't "return" from functions, just call
>the next function with the "result" of the current one.  I don't know
>what a C compiler would make of this, but a number of Scheme (and at
>least one Prolog) compiler transforms everything into this sort of
>code and consequently deals efficiently with it.  Of course, whether
>a continuation based program is easier to understand than one which
>uses explicit gotos is something I'll leave others to decide.

There are two major problems with this.  For one, the stack grows with
the non-returns, and taking care of this would be at least as bad as
garbage collection, if not worse, as stack locations are, for extremely
good reasons, not globally known.  For another, this does not handle
procedures which continue the resource use of the current procedure.

As an example, consider the use of g4, g16, and j in the code I have
posted.  These are produced in one block of code, and used in another.
There is no need to pass them.  In addition, whatever means are used
to get random bits and geometric random variables will likely use
pointers and registers across blocks.  Return involves at least partial
restoration of the state before the invocation, and this is neither
needed not wanted.

-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
Phone: (317)494-6054
hrubin@pop.stat.purdue.edu (Internet, bitnet)  
{purdue,pur-ee}!pop.stat!hrubin(UUCP)
Technical Details
Message-ID: <Bx6z1J.57r@mentor.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
References: <PSM.92Nov3165530@soma.sics.se> <1992Nov3.165005.18037@midway.uchicago.edu> <BEVAN.92Nov3211454@hippo.cs.man.ac.uk>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
From: hrubin@pop.stat.purdue.edu (Herman Rubin)
Subject: Re: A challenge to the anti-goto
Message-ID: <Bx6z1J.57r@mentor.cc.purdue.edu>
Sender: news@mentor.cc.purdue.edu (USENET News)
Organization: Purdue University Statistics Department
References: <PSM.92Nov3165530@soma.sics.se> <1992Nov3.165005.18037@midway.uchicago.edu> <BEVAN.92Nov3211454@hippo.cs.man.ac.uk>
Date: Wed, 4 Nov 1992 12:36:55 GMT
Lines: 43