20160122 Xmacro
.

Here I ask, what are the bare essentials of a syntactic macro system?


-- Scope

Consider a hacker who specialises at pressure projects in legacy settings.

They have a recurring experience of being sent in to solve a problem, but to
do so in settings where they are not allowed to install any third-party tools.
Sometimes they get an old, minimal-install Solaris host. Sometimes they get a
VAX with cobol or fortran. Sometimes they get an old MS-DOS computer with no
tools beyond debug.

The determined hacker becomes adept at strapping together a minimalist
toolchain from first principles. I want to understand what they should
construct.


-- Approaches

When I started thinking about this, my first thought was towards minimalist
languages that can be implemented as layers on top of another. It's plausible
to imagine scratching together r7rs in shell script or Forth in Fortran.

There may be an alternative. Consider if you could build a macro-language
around the tool, rather than a layer on top of it. This macro language would
serve a similar role to preprocessor that C compilers evaluate.

In the case where you were using debug.exe on DOS, you would build just enough
macro functionality to allow you to script things into debug.

Hypothesis: such a pattern exists, it is a more efficient solution than
bootstrapping forth, and it is closer to sed than scheme.

Let's attach a label to the pattern that would satisfy this, Xmacro.


-- Analogy to Turing completeness

A system is said to be Turing-complete if it can be used to simulate a system
of tape and markers called a Turing Machine. The Turing Machine describes the
bare essentials of a programmable machine.

The phrase "Turing-complete" is useful in conversation. Consider a discussion
about a tool. One person asks, "could you use it to model statistics?" Another
responds, "Yes, because it's Turing-complete."

I would like to know what is the analogue macro system.

We should be able to ask of a toolchain, "Will this strap Xmacro?"


-- Existing work

The goals of COLA seem to ask a similar question.
https://en.wikipedia.org/wiki/COLA_(software_architecture)

The derived project Ometa creates a parsing system on top of COLA.

Early releases of SNOBOL may hint at a path to Xmacro. The wikipedia page
states that SNOBOL BNF grammars are more powerful than regular expressions.


-- Success criteria

Xmacro needs to be at least as simple to implement as Forth.

Xmacro should have practical value. A test of this would be to implement it
in real-mode assembly on DOS, generating assembly output.