On Sat, Jun 6, 2020 at 5:50 PM Doug McIlroy wrote: > > Steve Johnson's position paper on optimising compilers may amuse you: > > https://dl.acm.org/doi/abs/10.1145/567532.567542 > > Indeed. This passage struck a particular chord: > > "I contend that the class of applications that depend on, for example, loop > optimization and dead code elimination for their efficient solution is of > modest size, growing smaller, and often very susceptible to expression in > applicative languages where the optimization is built into the individual > applicative operators." > > I don't know whether I saw that note at the time, but since then I've > come to believe, particularly in regard to C, that one case of dead-code > elmination should be guaranteed. That case is if(0), where 0 is the > value of a constant expression. > > This guarantee would take the place of many--possibly even > most--ifdefs. Every ifdef is an ugly intrusion and a pain to read. > Syntactically it occurs at top level completely out of sync with the > indentation and flow of text. Conversion to if would be a big win. > This came up on this list back in 2017 and I posted something about this at the time: https://minnie.tuhs.org/pipermail/tuhs/2017-January/009325.html If the language had been extended to support a "compile-type conditional" syntax ("if #(LINUX)", for example) it would have obviated the need for most preprocessor conditionals. As long as, syntactically, the compiler could tokenize a block in absence of e.g. type definitions, dead-code elimination could do the job. - Dan C.