Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/3/84; site talcott.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!talcott!tmb From: tmb@talcott.UUCP (Thomas M. Breuel) Newsgroups: net.lang.c Subject: Re: goto/forth Message-ID: <281@talcott.UUCP> Date: Thu, 21-Feb-85 21:38:55 EST Article-I.D.: talcott.281 Posted: Thu Feb 21 21:38:55 1985 Date-Received: Tue, 26-Feb-85 05:40:01 EST References: <8349@brl-tgr.ARPA> Organization: Harvard University Lines: 33 > Technically it is illegal to assign `a=b', altho some compilers allow > it. I read the release notes of a C compiler (pwb?) by dmr wondering > why a label could be passed to as an argument. It seemed to be > interpreted as a funxion ptr. Try using setjmp/longjmp to do this. setjmp/longjmp are slow, and they have the (in this case undesirable) side effect of re-storing automatic variables. When I was faced with the problem in a LISP interpreter, I came up with: #define transfer(f) return(fun)f fun next(); fun start() { transfer(next); } eval() { register fun kont=start; while(kont) kont=(fun)(*kont)(); } This is actually relatively fast and efficient (at least on a 68000). The price that you pay is that certain things (in particular in a LISP interpreter) become difficult because you can't really call eval recursively. In my case that does not matter, since the LISP evaluation stack is handled separately anyhow, and since I am using a non-recursive garbage collector, a pushdown automaton for the reader, ... . Thomas.