Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA Newsgroups: net.lang.c Subject: goto/forth Message-ID: <8349@brl-tgr.ARPA> Date: Wed, 20-Feb-85 12:29:40 EST Article-I.D.: brl-tgr.8349 Posted: Wed Feb 20 12:29:40 1985 Date-Received: Sun, 24-Feb-85 04:21:36 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 37 /* > I came up with the following piece of C code the other night. A friend and > I were talking about ways of writing a generic Forth interpretor in C. > We realized that the register save/restore at procedure call cost a lot > when you have lots of small routines (as in a forth interpretor). Also, > a large switch statement has expenses of its own. Then we thought about > indirect goto's. et voila: > > main() > { > int *a; > > b: > a = b; > printf("a = 0x%x\n", a); > } > > (NOTE: This was compiled under 4.2BSD on a -750) > > This compiles and runs perfectly. However, when adding an obvious statement > (namely, "goto *a") it won't let us compile it. It seems like the compiler > will *almost* let us do this. > > What I want to know is, "can this be easily added to the language?", > "Is it a reasonable thing to add?". Comments anyone? > > -- > -:--:- > David Herron; 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. jim */