On Thu, Jun 20, 2024 at 06:00:02PM GMT, René Nyffenegger wrote:
> I have a file with the following content:
...
> show_arguments(
>   divert(1)X`'divert(0)1st,
>   divert(1)Y`'divert(0)2nd)
> - - - - - -
> 
> 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?

Argument collection has priority over diversions.  divert() only
controls where the final output of top-level macro expansions will be
collected, but during argument collection, you are not producing
top-level output.

Perhaps the manual could be improved with an example showing this
pitfall, as you are not the first to question it.  But this is not
unique to GNU M4; other historical implementations also have this same
behavior of prioritizing argument collection over macro expansion
output (I just tested FreeBSD's m4 at
https://instantworkstation.com/virtual-machine to confirm).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


Reply via email to