[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: There is a bug in m4 tracing
From: |
Stepan Kasal |
Subject: |
Re: There is a bug in m4 tracing |
Date: |
Wed, 29 Mar 2006 11:55:46 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello,
> Witness the following typescript:
looks right to me.
Let me explain; let's start with your definition:
> define(`foo', `This is the macro `foo'.')
The most natural way to use this macro as a parameter would be this:
> define(`echo3', `$1')
> echo3(`foo')
(Note that the parameter is quoted.)
echo3 would get one parameter, <foo> (without the angle braces, of
course). So it would expand to <foo>. And this would expand to
This is the macro `foo'.
which is expanded word by word and ends up as
This is the macro foo.
Back to your example:
> define(`echo1', `$*')
> echo1(foo)
Since the parameter is not quoted, it is expanded during the parameter
scan for echo1. So first <foo> is expanded to <This is the macro `foo'.>
and then to <This is the macro foo.>---and this is what becomes the
parameter for echo1.
Then echo1 is expanded, and we get <This is the macro foo.>
Then this is expanded word by word, so we get
This is the macro This is the macro `foo'..
and
This is the macro This is the macro foo..
To sum up, the macros were expanded in this order:
foo, echo1, foo
> define(`echo2', `$@')
> echo2(foo)
This is similar, but $@ becomes <`This is the macro foo.'> and thus the
macro foo is not expanded once more, so the list is:
foo, echo2
One final note:
> m4trace: -2- foo
The number 2 means that foo is expanded during the scan for parameters of
echo1.
Hope this helps,
Stepan Kasal