A new version of www.cs.dartmouth.edu/~doug/barem4.m4 enables
functional programming within m4. This thoroughly annotated
implementation of barem4 uses no builtin macros other than `define',
thereby demonstrating that the heart of m4 is Turing complete. In
particular, it provides conditional execution and a full complement of
arithmetic and comparison operations on unlimited-precision binary
integers. The most notable advances over the original version are

1. Equality testing of arbitrary identifiers, not just predefined sets
of identifiers.

2. Handling of encoded strings of alphanumerics.

3. Iteration over lists.

4. Higher order functions `foldl',  `foldr', and `zip' inspired by Haskell.

5.  More exploitation of m4 to generate code for itself.

A test suite, www.cs.dartmouth.edu/~doug/testbarem4.m4 accompanies the
file of m4 definitions.

Building on barem4, Eric Blake has made a simulator of an "intcode"
computer capable of running impressive applications.

Doug

Reply via email to