help-make
[Top][All Lists]
Advanced

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

Re: 8.6 The call Function


From: Philip Guenther
Subject: Re: 8.6 The call Function
Date: Sat, 11 Jun 2011 10:21:30 -0700

On Sat, Jun 11, 2011 at 3:42 AM, ali hagigat <address@hidden> wrote:
> 8.6 The call Function
> The call function can be nested. Each recursive invocation gets its
> own local values for
> $(1), etc. that mask the values of higher-level call.
> map = $(foreach a,$(2),$(call $(1),$(a)))
> o = $(call map,origin,o map MAKE)
> ------------------------------------
> It seems that $(1) is "origin" in each iteration of 'foreach'. If not
> what it is then?

While that example illustrates how $(call) can be tested, with a
called function itself using $(call), it doesn't really illustrate how
$1 and similar take different values, with each new $(call) shadowing
the current values.  Well, I guess you can say that $1 takes a
different value in each call to $(origin), but since that's a built-in
we really can't "see" the change.  If we add an intermediate function,
perhaps it would be clearer:

map = $(foreach a,$(2),$(call $(1),$(a)))
verbose_origin =The origin of $1 is $(origin $1).
o = $(call map,verbose_origin,o map MAKE)

That sets $(o) to "The origin of o is file. The origin of map is file.
The origin of MAKE is default."  While $(map) is being expanded,
$(verbose_origin) is called, so that $1 is set to 'origin' inside
$(map) but, *concurrently*, inside the three calls to
$(verbose_origin), $1 is set to 'o', 'map', and 'MAKE'.

Does that make the documentation's bit about how each "gets its own
local values for $(1), etc" clearer?


Philip Guenther



reply via email to

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