
Ace: a syntax-driven C preprocessor (1989) [pdf] - kazinator
https://swtch.com/gosling89ace.pdf
======
tjalfi
Xoc[0] is a newer extensible C compiler. The project ended in 2008 but the
papers are worth reading.

[0]
[https://pdos.csail.mit.edu/archive/xoc/](https://pdos.csail.mit.edu/archive/xoc/)

~~~
zokier
A distant cousin of Golang? One of the major example extensions Cox provides
in his paper is Alef-style channels, which naturally (considering the lineage)
feels similar to what Go has.

------
ktpsns
Unusual preprocessors in longstanding classical languages such as C and
Fortran should be a well-considered decision. I know a particular example of a
mature Fortran code which must be preprocessed with a weird perl script which
enriches the Fortran notation with some semantic meaning of the array indices.
We can do something similar now in a C++ code which uses templates but can be
compiled without any tricks.

My personal bottom line: Better stick to the language canon and switch the
complete infrastructure then only parts of it, except it is a small developer
group or exceptional documentation.

~~~
kazinator
> _We can do something similar now in a C++ code which uses templates but can
> be compiled without any tricks._

That's nice, but you cannot do that in Fortran without that perl script, so
apples and oranges.

That perl script cannot possibly be a worse dependency containing more
technical debt than C++.

------
mistrial9
"here is a routine for drawing vectors using Bresenham’s algorithm."

[https://en.wikipedia.org/wiki/Bresenham's_line_algorithm](https://en.wikipedia.org/wiki/Bresenham's_line_algorithm)

~~~
kazinator
> It is possible to use this technique to calculate the U,V co-ordinates
> during raster scan of texture mapped polygons {citation-needed}

Way back as an undergrad student, I suspected this, after successfuly
implementing the rendering of hyperbolic (y = A/x) curves with Bresenham. It
hit me; that /x could be the perspective divide by z; that vertical coordinate
could be marching through texture space. Never tried it, though.

------
Hemospectrum
Neat. This looks a lot like GHC’s rewrite rules (used to define loop fusion
optimizations, among other things) except that Haskell doesn’t have to worry
about side effects quite as much and the whole system is simpler as a result.

------
bangonkeyboard
Has anyone here tried to use m4 as a CPP replacement?

~~~
rwmj
Good christ no, m4 is one of the worst macro preprocessors.

If you're going to preprocess C code then you should use something which is
aware of the syntax of C (analogous to camlp4 for OCaml). There are a bunch of
"LISP macro for C" projects out there.

~~~
bangonkeyboard
The reason I even considered m4 is its ubiquity; since it's mandated by POSIX,
it wouldn't be another external build dependency if I wanted more powerful
(but more painful) preprocessing.

~~~
fao_
If you're after POSIX compliance I'd use sed(1) and dc(1) before I touched
m4(1)

------
ksherlock
Did it ever escape the Sun?

