[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macro defining macros...
From: |
Gary V. Vaughan |
Subject: |
Re: Macro defining macros... |
Date: |
Fri, 04 Feb 2005 14:03:43 +0000 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041103) |
Hello Carlo,
Carlo Contavalli wrote:
> Hello, I'm not subscribed to the list (can you carbon copy
> my address when replying?) and couldn't find any reference
> in the manual...
> I'm trying to do something like:
>
> define(`macro1', `define(`macro2', `$0 -- $1 -- $2')')
> macro1
> macro2(foo, bar)
Positional parameters are expanded without regard to nested
quotes, so when macro1 is called $0, $1 and $2 are expanded
inside its body.
macro1
=> define(`macro2', `macro1 -- -- ')
=>
macro2(foo, bar)
=> macro1 -- --
=> define(`macro2', `macro1 -- -- ') -- --
=> -- --
You can defer the expansion by obfuscating the parameters:
define(`macro1', `define(`macro2', `$'`0 -- $'`1 -- $'`2')')
macro1
=> define(`macro2', `$0 -- $1 -- $2')
=>
macro2(foo, bar)
=> macro2 -- foo -- bar
=> macro2 -- -- -- foo -- bar
=> macro2 -- -- -- -- -- foo -- bar
=> ...
You can fix the infinite loop with a pushdef, or changequote.
HTH,
Gary.
--
Gary V. Vaughan ())_. address@hidden,gnu.org}
Research Scientist ( '/ http://tkd.kicks-ass.net
GNU Hacker / )= http://www.gnu.org/software/libtool
Technical Author `(_~)_ http://sources.redhat.com/autobook
signature.asc
Description: OpenPGP digital signature
- Re: Macro defining macros...,
Gary V. Vaughan <=