From mboxrd@z Thu Jan 1 00:00:00 1970 From: doug@cs.dartmouth.edu (Doug McIlroy) Date: Thu, 08 Sep 2016 08:35:28 -0400 Subject: [TUHS] Comments on "C" Message-ID: <201609081235.u88CZS8W017103@coolidge.cs.Dartmouth.EDU> > After about 30 years of C, there are only three things I would have liked to see: > 1. Computed goto ... > Computed goto's are good for interpreters. A computed goto, of course, is merely an optimized switch. Dennis installed this optimization early in the evolution of C. The main driving force was the performance and size of the PDP-11 Unix kernel. As functionality grew, resource usage was repeatedly tamped down by improving C's code generation. The switch optimizer chose among three strategies: naive, binary decision tree, and computed goto, depending on the number and density of switch alternatives. Hybrid strategies may have been used, too, but my memory is hazy on this point. In particular the optimization improved system-call dispatch--thus achieving the objective, "good for interpreters". I assume (I hope not unrealistically) that this optimization has been in the repertoire of mainline C compilers ever since. > (Or perhaps require C to support tail recursion.) I can imagine making a strong recommendation in the standard for optimizing switches and (at least direct) tail recursion. Doug