[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Comments on changesyntax et al.

From: Daniel Richard G.
Subject: Comments on changesyntax et al.
Date: Fri, 9 Feb 2007 12:15:15 -0500


I just recently discovered m4's progress toward version 2.0. There's a 
*lot* to like in the feature list, and I'm glad to see the project isn't 
stuck in maintenance mode.

I've been dealing a bit with macro processors lately, with some 
frustration. Please consider the following as an outsider's perspective, or 
a hopefully reasonable use-case scenario:

I've been looking for a macro processor to implement a LaTeX-like language 
for Web design. With "classic" m4, this is impractical, because unless you 
meticulously quote everything, commas in ordinary text are a pain to deal 
with. I worked with a different program (GPP) for a while, as it allows 
near-complete customization of the macro syntax (and even supports a 
TeX-like scheme out of the box), but it lacks some of the nicer features of 
m4 like patsubst() and diversions.

The new changesyntax() builtin is very enticing. I noticed that in (CVS) 
m4/examples/WWW/m4lib/ there is even a LaTeX-like Web design macro language 
already elaborated.

There are some pretty clear limitations to it, however. The biggest one for 
me is that you cannot make the macro argument separator a multi-character 
sequence, so you have to settle for

        \macro{arg one, arg two, arg three}

or perhaps something like

        \macro{arg one|arg two|arg three}

instead of the more LaTeX-like

        \macro{arg one}{arg two}{arg three}

which is what I want, not least because it all but does away with the need 
to quote the arguments.

Many of the other syntax categories can usefully be specified as 
multi-character sequences, too. In fact, aside from the following 

        White space

...it seems a bit awkward to define them using a set of characters, given 
that the set is nearly always of size 1. Even if you have, say, the 
following hypothetical sets of size 2...

        Open paren  => "(["
        Close paren => ")]"

...m4 won't recognize (let alone enforce) proper nesting; "foo(bar]" would 
be a valid macro call. I don't see how a set-of-characters match is 
well-suited for defining these sorts of syntax categories.

On a different note, may I make a feature suggestion/request? I see that 
two of the syntax categories address "extended argument references." These, 
from what I can tell, work the same way as standard argument references, 
except for the extra bit of syntax protection---you can say e.g. 
"1111${2}1111" safely.

But that wasn't obvious to me at first, and for a moment I was thinking m4 
had gained support for named arguments. Which would have been a really, 
really nice feature to have. Something where you could do e.g.

        => define(`foo', `The ${noun} is ${verb}.')
        => foo(noun = `fox', verb = `running')
        The fox is running.

But then the order of the arguments wouldn't matter, and you could have 
macros that potentially take a large number of args but only a handful in 
normal use---the example that comes to mind is a BibTeX citation.

(Now, currently, you can get a similar effect by using more macros, e.g.

        => define(`foo', `The noun is verb.')
        => define(`noun', `fox')
        => define(`verb', `running')
        => foo
        The fox is running.

But then you have to worry about namespace pollution/collisions with the 
"argument names," especially if you favor shorter ones. Not ideal.)

Any comments on the above would be appreciated,


NAME   = Daniel Richard G.       ##  Remember, skunks       _\|/_  meef?
EMAIL1 = address@hidden        ##  don't smell bad---    (/o|o\) /
EMAIL2 = address@hidden      ##  it's the people who   < (^),>
WWW    = http://www.******.org/  ##  annoy them that do!    /   \
(****** = site not yet online)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]