Ah yes, the M word. I think I added my own bit to the confusion, tho not, I hope, to the flames. What is clear is that there are a couple of definitions of "macro" floating around. They overlap but don't coincide; and there are a couple of different types of "macro" in abc which fit into one definition but not the other.
The subject seems to be returning, carrying its usual confusion, so I looked up the definitions to see what they said.
First, in my on-line Websters, a macro is defined as:
macro n, pl macros [short for macroinstruction] (1959): a single computer instruction that stands for a sequence of operations.
However, the new Hacker's dictionary defines it:
macro /mak'roh/ techspeak n. A name (possibly followed by a formal arg list) which is equated to a text or symbolic expression to which it is to be expanded (possibly with the substitution of actual arguments) by a macro expander.
There's more---I'll get back to that---but note that there is
quite a difference in the two definitions. Webster's definition is pretty
general while the Hacker's definition is more specific: it tells you not
only what a macro is, but how it is accomplished (by a macro expander). Kind of strange if you think of it---if you wanted to be really careful
(perish the thought!) you'd say that a macro was an ordered pair, macro
plus expander. On the other hand, the hacker's definition is not limited
to "instructions," while Webster's is. There is a third definition that
I've heard on this list: a macro is a text substitution.
Historically, the definitions aren't that different. To someone programming in 1959 using a macro assembler, it was a BIG advantage to be able to type in a short keyword or two to put in a common idiom, rather than type blocks of the same code over and over again.
Likewise, to someone using the text editor TECO in the early 1970's, it was nice to be able to hit a single, special key and get a common editing idiom, rather than type long sequences of editor commands over and over again. I find it amusing to hear Unixy folk complaining about WordPerfect and Microsoft Word adding keyboard macro capability to teir word-processors, when emacs started out as a macro collection for TECO.
Lisp programmers swear by their macros. They allow, once again, common idioms to be typed in rather simply instead of typing on long blocks of code over and over again.
All of these early uses of macros, as well as most later ones, work via some variation of text substitution. The macro assembler is more "pure" along those lines. The keyboard macros does the substitution as you type, the lisp macros manipulate parse trees instead of text directly.
Even TeX macros are really text substitution, which Knuth makes clear in his documentation.
To a certain degree, the Webster sense was the original intent, with the Jargon file sense being the method. However, it is a very powerful, flexible method, and can (and is) used for much more than simply using a single instruction instead of a set of them.I'd always understood "macro" in the Webster's sense, having run into them principally in TeX and in keyboard macros for text editors, so I was surprised when this usage led to confusion. Now I understand why.
I once wrote a 2-pass SPARC assembler using m4, a single-pass macro package.
I think that ESR is incorrect here, at least as far as distinguising "keyboard macros" as "macro-like entities". Historically, keyboard macros have been called macros, and have worked via textual substitution for a long time.The jargon file goes on to say,
"Indeed the meaning has drifted enough that the collective 'macros' is sometimes used for code in any special-purpose application control language (whether or not the language is actually translated by text expansion), and for macro-like entities such as the 'keyboard macros' supported in some text editors (and PC TSR or Macintosh INIT/CDEV keyboard enhancers)."
The confusion in abc comes from the fact that there are a coupleI'm not sure I like the syntax 100%, since it distinguishes a particular letter as "the" argument. Is there a way to write a Phil Taylor macro that uses an 'n' in the name of the macro?
of types of macros (or "macro-like entities") floating around: First,
Phil Taylor's Barfly macros seem to fit the Hacker's definition nicely. (Even his transposable macros fit, since the definition allows arguments,
and these take a note as an argument.)
I'd not call that a "macro" feature, but rather an "escape" feature. (There's a better, more proper word for it that I can't think of at 6am.) It allows you to "escape" the ABC translator and talk to the underlying MusixTex processor. Of course, it's accessed through a macro feature ;-) I'd consider them to be two different things, myself.
However, there is another kind of m-le which is used in abc2mtex,
and has been there since very early versions. (This program might be
thought obsolete by some, but not by me, since I need these things, and
that's the only program that offers them.) For those only familiar with
abc2ps, abc2mtex is a front end for TeX/MusiXTEX, which itself has an
extensive macro facility; MusixTeX can print out quite good staff music,
including symphonic scores if you want them. The way the m-le works in
abc2mtex is this: when you need something not offered by abc, you can
write a TeX macro which will do it, and then attach it to one of the
letters H--Z. When abc2mtex encounters that letter, it simply passes the
name of the macro on to TeX (Sometimes adding the note as an argument). Then TeX expands it when it processes the abc2mtex output.
The problem with such escapes is that they are inherently non-portable, across backends. Similar escapes exist in abc*2ps (or at least, that's what I'm interpreting it meaning when I see raw PostScript flung across this list).But they could also be incorporated in abc itself, although this would require some fairly radical development, such as the creation of a built-in macro language.
What could be useful in ABC is three new "macro-like" things:
1) "long macros" -- Phil Taylor's m: macros. These are prefixed in the ABC music with a special character, like ~, or @ or something, and can, through some syntax put, take an argument specifying a musical note (or something else... perhaps ~ macros could take a musical note if there was an 'n' in the macro name, and a @ macro could take a more free-form argument with a {} notation. Allowing someone to come up with a @instrument{...} macro that could be used to signify instrument changes.)
2) "single-character macros" -- The infamous U:X=!...! macros, but perhaps repackaged in a saner form. Pure text substitution, no arguments. Limited number of characters useful for the macro name, therefor of limited use. The most common use will probably be for specifying unusual ornamentations not otherwise covered in the ABC standard, but could concievably be used for other things as well.
3) "escapes" -- abc2mtex TeX macro facility, but generalized. Some sort of syntax to indicate that the following code should be sent directly to the underlying back-end processor, not processed by ABC directly.
There is a lot of possibilities for combinations thereof, especially if it was written that during the macro-expansion phase, parsing would start at the beginning of the expanded text. Phil mentioned a ~n3 macro, that would perform a roll the way a piper would. But I can easily see there being more than one alternative method of playing that someone might want to notate as ~n3, in the same piece.
Hmmm... I'm having some ideas... Let me ponder them, and possibly suggest a more general macro facility...
To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html
