Path: utzoo!attcan!uunet!seismo!esosun!jackson From: jackson@esosun.UUCP (Jerry Jackson) Newsgroups: comp.lang.fortran Subject: Re: Assigned GOTO Message-ID: <222@esosun.UUCP> Date: 7 Jul 88 21:51:00 GMT References: <2742@utastro.UUCP> <20008@beta.UUCP> <224@raunvis.UUCP> <12215@mimsy.UUCP> <2261@sugar.UUCP> <3350@s.cc.purdue.edu> Organization: SAIC, San Diego Lines: 42 In-reply-to: ags@s.cc.purdue.edu's message of 7 Jul 88 14:54:27 GMT Someone asked for uses for the assigned goto. Until this discussion, I did not know Fortran had such a beast. However, I know of an application where I would dearly have loved to have it. (I'm mostly a Lisp/C hacker..) I wrote a Scheme interpreter in 'C'. One of the properties of Scheme is that procedure calls MUST be tail recursive -- hence, the 'C' function calling mechanism was not applicable to Scheme function calls. What I had to do was simulate a procedure call/return sequence. To do this right, you have to be able to push return addresses (i.e. labels) on an explicit stack, then pop them and goto the result. C does not allow you to 'goto' the value of a variable -- If it did, I could have written a much more efficient interpreter. I would have liked to have written: pop(ReturnAddress); goto ReturnAddress; Instead, I had to use a giant switch statement on tags that looked like: pop(ReturnAddress); switch (ReturnAddress) { case APPLY: code for apply...; case XXXX: code for XXXX...; . . . } I spent much time cursing 'C' for not having an assigned goto. +-----------------------------------------------------------------------------+ | Jerry Jackson UUCP: seismo!esosun!jackson | | Geophysics Division, MS/22 ARPA: esosun!jackson@seismo.css.gov | | SAIC SOUND: (619)458-4924 | | 10210 Campus Point Drive | | San Diego, CA 92121 | +-----------------------------------------------------------------------------+