4 ms·
Around 1966, two notable programming languages were developed around the notion of macro expansion. One of these was Christopher Strachey's GPM (General Purpose
by todd8 11y ago
Around 1966, two notable programming languages were developed around the notion of macro expansion. One of these was Christopher Strachey's GPM (General Purpose Macrogenerator) and Calvin Moore's Trac(tm) system. GPM, perhaps because of Strachey's academic reputation (he taught at Oxford and is well known for denotational semantics), seems to have had a greater influence in Computer Science.
Trac(tm), on the other hand, had an important booster, it was promoted in Ted Nelson's 1974 cult classic Computer Lib, one of my treasured historical CS books that I bought in grad school the first time around. Nelson (famous for inventing hypertext, the notion of embedded active links decades before HTML) wrote that "You can and must understand computers now." He suggested learning three languages: BASIC, TRAC, and APL--all languages that he felt you could learn on your own. Trac, and the remarkably similar GPM, are very simple. I've implemented Trac-like systems several times. It's a fun project to implement in an afternoon when learning a new programming language.
What made these two languages interesting is that they are equivalent to a Turing machine and hence capable of arbitrary computations. Furthermore, they really aren't impractical to use (but see my comments below). If locked in a dungeon by an evil genie and forced to write a real program on bare hardware before I could be released, I would certainly consider developing TRAC or GPM as the first step (or maybe FORTH).
m4, developed by Kernighan and Ritchie in 1977, looks like it was inspired by GPM. It's been a useful tool for me a number of times, but it is good to not let it's generality and flexibility suck you into outsmarting yourself.
The power of these macro systems (and TeX's as well) comes from the arbitrary rewriting that they enable, a bit like Chompsky's Type 0 (unrestricted) grammars in his hierarchy. These macro systems, once popular, have now fallen out of favor. Although almost trivial to implement, programming in them is a bit like playing Othello, it's hard to see very far ahead: what will unfold when a macro that will be expanded is passed arguments that will be re-expanded.
Sendmail's configuration files are processed by m4--seemed like a cool idea in the early 1980's--but that made it hard for non-experts to understand what was happening.