Re: problem embedding argument inside nested macro def's

"Piotr Wysocki" <[email protected]>
Newsgroups gmane.comp.gnu.m4.general
Message-ID <[email protected]>
Eric,

On Sat, Jun 28, 2008 at 7:38 AM, Eric Blake <[email protected]> wrote:
> From: "Piotr Wysocki":
>> What is the correct syntax to achieve my goal?
>
> You need to use a helper macro, and supply any instance of
> $ followed by a special character that must appear literally
> in the nested define as independent literally-quoted strings
> in the forwarding macro.  Something like this (but untested,
> since I'm not at my regular computer):

Your help is appreciated. Thank you.

Your example worked nearly as I wanted, you just
mispelled $1 with $2 in one place ;-)

>
> divert(-1)
>
> define(`___DEF', `_$0(`$1', `$'`1')')
> define(`____DEF', `define(`__$1', `define(`_a$2', `a$2')')')
> dumpdef(`___DEF')
> ___DEF(`T')
> dumpdef(`__T')
> __T(`abc')
> dumpdef(`_aT')
>
> divert(0)dnl
>
> Note how ___DEF now calls ____DEF with two arguments,
> the `$1' argument handed to ___DEF, and the literal argument
> consisting of `$' concatenated with `1'.  That way, in ____DEF,
> use of $1 refers to the argument of ___DEF, and use of $2 refers
> to the deferred string $1 for use in the second round of defines.

Yeah, now I understand it. I is unfortunate that this solution
didn't come up to my mind alone :(

Thanks again.

Cheers,
Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.