Re: named arguments in m4?

Daniel Goldman <[email protected]> Mon, 21 Apr 2014 15:18:01 -0700
Newsgroups gmane.comp.gnu.m4.general
Message-ID <[email protected]>
On 4/21/2014 8:53 AM, Gary V. Vaughan wrote:

> For the record, the syntax I briefly implemented simply involved defining a macro
> with a parameter list, and then referring to parameters by name in the body of the
> macro:
>
>    m4_define(`exch (parm1, parm2)', `$parm2 $parm1')
>    exch(`foo', `bar')
>    bar foo
>
> It's still something I'd like to have one day, but I'm not sure I like that syntax...
>
> Cheers,
>

Actually, that syntax looks reasonable to me. Your syntax is certainly 
better than the suggestion I made, which I find confusing. At first 
glance, your syntax seems pretty clear. And it's good that it resembles 
the cpp syntax:

#define EXCHANGE(arg1, arg2) arg2 : arg1
EXCHANGE(Arg #1, Arg #2)

I imagine adding new capabilities to m4 is a huge amount of detailed 
work. Thank you for answering my newbie question. I might have some 
other questions in the future, as I explore m4.

I previously used cpp, sed, and "htp" for various text pre-processing 
tasks I'm mostly moving over to m4. I wish I had learned m4 before. 
Thank you for having this discussion group.

Daniel