m4-discuss
[Top][All Lists]
Advanced

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

Re: expansion


From: Eric Blake
Subject: Re: expansion
Date: Mon, 30 Nov 2009 06:32:25 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Josef Vukovic on 11/29/2009 8:08 PM:
> Hello,
> 
> Can I stop the expansion of a marco after it has been expanded?
> 
> for example:
> 
> define(foo,bar)
> define(foo,baz)

At this point:

defn(`foo')
=> bar
defn(`bar')
=> baz

If, on the other hand, you do:

define(`foo', bar)
define(`foo', baz)
defn(`foo')
=> baz
defn(`bar')
=>

that is, bar remains undefined.  This very problem of defining an
unintended macro name if you forget to use proper quoting is why it is
almost always a good idea to quote the first argument to define.

Thus, defn is a way to get at the contents of a defined macro without
further expansion.

Also, if you wait for me to ever get enough time to release m4 1.6 (or, if
you build from git), you can play with the new builtin qindir, which is
similar to defn in that it can show quoted contents of a macro definition,
but different in that it also performs $1 substitution more like a regular
macro expansion.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksTyWgACgkQ84KuGfSFAYCCwQCgkp+ridvzJBpUXAq2T5ecg5yy
3iQAnRjpxI9ep+BhNww5eRTf9ys2wYqj
=A14x
-----END PGP SIGNATURE-----




reply via email to

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