Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: federation2005@netzero.com Newsgroups: comp.compilers Subject: How to type braces for computed gotos (was: Best "simple" C Compiler I've ever seen) Date: Fri, 18 Jul 2014 14:44:04 -0700 (PDT) Organization: Compilers Central Lines: 31 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-07-033@comp.compilers> References: <14-05-013@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: miucha.iecc.com 1405732972 28770 2001:470:1f07:1126:0:676f:7373:6970 (19 Jul 2014 01:22:52 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 19 Jul 2014 01:22:52 +0000 (UTC) Keywords: C Posted-Date: 18 Jul 2014 21:22:52 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com X-Received-Bytes: 2682 X-Received-Body-CRC: 1256577170 Xref: csiph.com comp.compilers:1323 On Sunday, May 4, 2014 8:23:05 PM UTC-5, andrewc...@gmail.com wrote: > https://github.com/rui314/8cc > Self hosting, extremely well written, and seems geared towards simple > but complete code rather than being a complicated monolith. On that count: usually when I redo a source (reformat, reanalyze the math, make more effective use of the language, etc.) it comes out to 50% reduction by lines 30% by bytes; which is consistent across thousands of source files. The only exceptions I've encountered to date are stuff I earlier reduced (30% by lines if it made use of an earlier dialect of the language), stuff from AT&T (which does not reduce much, e.g. CFront) and the source for this compiler. So by that count, it's well-written and compact. There is one feature the compiler tests for that I assume the language also has in it that I haven't seen much of before: the computed goto. What's I don't quite understand how the branches are being typed. A computed goto inside a void routine has the branches typed (void *), with the individual items accessed in effect as references to (void *). The branches are essentially continuations. So the question here is how are continuations being typed. From the example used in the distribution, either (A) all continuations are typed (void *) or they are being typed (T *) when they occur inside a function that returns type T. [That's an extension. In standard C, you can only goto a label. -John Perhaps it's similar to this GCC extension https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html#Labels-as-Values]