Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ihnp4!ptsfa!lll-lcc!mordor!sri-spam!rutgers!dayton!umn-cs!herndon From: herndon@umn-cs.UUCP Newsgroups: comp.lang.c Subject: Re: Re: X3J11: Why no labelled loops? Message-ID: <53900004@umn-cs.UUCP> Date: Sun, 1-Mar-87 19:30:00 EST Article-I.D.: umn-cs.53900004 Posted: Sun Mar 1 19:30:00 1987 Date-Received: Tue, 3-Mar-87 23:51:30 EST References: <388@cognos.UUCP> Lines: 31 Nf-ID: #R:cognos:-38800:umn-cs:53900004:000:1658 Nf-From: umn-cs!herndon Mar 1 18:30:00 1987 >In article <388@cognos.UUCP> brianc@cognos.UUCP (Brian Campbell) writes: > Why are labelled loops not supported in ANSI C? >>/* Written 7:17 pm Feb 87, 19783 by mntgfx!franka in umn-cs:comp.lang.c */ >> >>Now for my pet peeve. Why can't you take the address of a label? ... >> label *jump_table[] = { &exe_seg_0, &exe_seg_1, ... }; >>... justifications for this ... >...... In fact, I wonder why this idea has not been implemented before... >Frank Adrian >Mentor Graphics, Inc. In fact, this *used* to be legal, and has been done. In days of old (when knights were *ahem*) labels had type (int *). Thus a programmer could quite easily load an array full of label values and happily goto . It peeves me greatly too, since I would like to maintain my own call stack for a threaded interpreter; allowing the C compiler to maintain it will cost me >>10 times the space. (I can code the info needed to save and restore my environments in less than 2 bytes; the stacks may grow very deep: ~= 100K procedure calls.) Since I can't use arrays of labels, I either: 1) Have to use a machine dependent hack for jumping to the code 2) Have to maintain the stack myself, iteratively calling procedures which do what I want, while passing add'l call/return info with the calls and returns, costing me the time of the procedure call and return, and forcing me to generate useless prologue/epilogue code for each procedure. The former prohibits me from uniformly mixing dynamically generated and statically compiled code. The latter uglifies code generation and costs time (procedure overhead) and space (code) performance.