m4-discuss
[Top][All Lists]
Advanced

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

Re: diversion while collecting arguments


From: Douglas McIlroy
Subject: Re: diversion while collecting arguments
Date: Fri, 21 Jun 2024 18:42:59 -0400

I think of m4 as a switchyard for data streams. There are various internal flows, e.g. to or from arguments, and to or from macro definitions. divert() affects only the (normally) external output flow, capturing it instead somewhat like a macro definition--but eventually simply copied to the external output (not via macro expansion). "Somewhat like" recognizes the fact that a new define() for an old name replaces text, whereas a new divert() to the same destination adds text.

I hope this helps.

Doug.



On Thu, Jun 20, 2024 at 12:21 PM René Nyffenegger <mail@renenyffenegger.ch> wrote:
I have a file with the following content:

define(show_arguments, `arg-1 = $1
arg-2 = $2
')

divert(1)A`'divert(0)a

show_arguments(
   divert(1)X`'divert(0)1st,
   divert(1)Y`'divert(0)2nd)

divert(1)B`'divert(0)b

- - - - -

m4 processes this file to:

a

arg-1 = X1st
arg-2 = Y2nd


b
AB

- - - - - -

I expected the
     divert(1)X`'divert(0)
and
     divert(1)Y`'divert(0)2nd)

to divert the X and Y so that it is emitted at the end.

Can someone explain why this is not the case?

Thanks

Rene



reply via email to

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