[Top][All Lists]

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

Re: problem embedding argument inside nested macro def's

From: Piotr Wysocki
Subject: Re: problem embedding argument inside nested macro def's
Date: Sat, 28 Jun 2008 14:29:50 +0100


On Sat, Jun 28, 2008 at 7:38 AM, Eric Blake <address@hidden> 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.


reply via email to

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