autoconf
[Top][All Lists]
Advanced

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

Re: m4_foreach_w vs m4_foreach


From: Eric Blake
Subject: Re: m4_foreach_w vs m4_foreach
Date: Wed, 04 Jul 2012 04:50:07 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

On 07/04/2012 12:58 AM, Vincent Torri wrote:
> 
> 
> On Mon, 2 Jul 2012, Eric Blake wrote:
> 
>> Not directly with a single m4_foreach_w, but it would be possible with
>> other macro constructs.  Note that m4 is better suited for
>> comma-separated lists instead of whitespace-separated lists,
> 
> when you say 'better suited', you mean faster ?

Yes.  m4_foreach_w is more or less a wrapper that converts spaces into
commas, then calls m4_foreach on the comma-separated result.  Starting
with comma-separated lists in the first place can use native m4 handling
rather than having to do under-the-hood conversions.

> 
> I ask because I used a simple macro that uses m4_foreach_w. Should I use
> m4_foreach instead ?

That all depends on the syntax you want your users to be aware of.
There are some cases where whitespace-separated lists are easier for
users to type.  Furthermore, in autoconf particularly, there is a
benefit to using whitespace separation when you are interacting with
shell code output (for example, having the flexibility to write 'for i
in $1; do', but also do m4 processing on each element of $1).  In other
words, the trade-off between m4 speed and ease of use is not always trivial.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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