[Top][All Lists]

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

Re: please clarify the manual on foreach function?

From: Paul Smith
Subject: Re: please clarify the manual on foreach function?
Date: Fri, 18 Feb 2011 17:34:24 -0500

On Fri, 2011-02-18 at 11:50 -0800, Mark Galeck (CW) wrote:
> Hello, the manual says:
> "The syntax of the foreach function is:
>      $(foreach var,list,text)
> The first two arguments, var and list, are expanded before anything
> else is done; note that the last argument, text, is not expanded at
> the same time. Then for each word of the expanded value of list, the
> variable named by the expanded value of var is set to that word,
> and text is expanded. Presumably text contains references to that
> variable, so its expansion will be different each time.
> The result is that text is expanded as many times as there are
> whitespace-separated words in list. The multiple expansions
> of text are concatenated, with spaces between them, to make the result
> of foreach."
> Questions:  1.  When I read the above carefully, it does not really
> say that the expansions of text are concatenated _in the same order_
> as in list.  Is this guaranteed or not?

Yes.  The function walks <list> one word at a time in order, assigns the
word to <var>, and expands <text>.  The result of all these expansions
(in order) is the result of the foreach.

> 2.  Again when I read carefully, it does not say the expansion happen
> "serially" that is, in time, one after another.  Make could presumably
> do all of them in parallel, especially when invoked with -j<multiple>
> remember the results and then concatenate (in some order) when it is
> done.  Is this guaranteed to happen serially??

Well, I think you misunderstand what -j does.  All it does is allow make
to have multiple jobs (that is, sub-programs) active at the same time.

It does NOT allow make itself to run "in parallel" in any way.  Make is
a single-threaded application, always: it has no multithread capability.
The processing internal to make is always sequential, one at a time

The -j option simply allows make to continue on with the next job
without waiting for the previous one to finish.

reply via email to

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