help-make
[Top][All Lists]
Advanced

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

Re: about immediate and deferred variable assignment in GNU make


From: Lin George
Subject: Re: about immediate and deferred variable assignment in GNU make
Date: Wed, 26 Apr 2006 08:04:35 -0700 (PDT)

Thanks Paul!
 
 
Your sample is so great!
 
> $(info B is $(B))
 
What do you mean "info B is $(B)"?
 
> A recursive variable (expansion is deferred) will have to be expanded
> every time the variable is referenced. Any variables in the value
> expand to their CURRENT values, not what they were when the simple
> variable was assigned.
 
I am just curious why you call a variable "recursive variable" and "simple variable". I think in your context, "recursive variable" means the variables which is assigned value many times and "simple variable" means variable which is assigned value only once.
 
Also, "referenced" mean assign a value to a variable. :-)
 
regards,
George

"Paul D. Smith" <address@hidden> wrote:
%% Lin George writes:

lg> After reading the above statement several times, I am still
lg> confused about what mean immediate assignment and what means
lg> deferred assignment. Could anyone show me an example please?

An example:

# deferred
A = bar

# deferred -- B has the value '$(A)'
B = $(A)

# immediate -- C has the value 'bar'
C := $(A)

# deferred -- change A to another value
A = foo

# immediate -- B is expanded in order to be printed
# This prints "foo", not "bar", because the reference to A is
# expanded here not back when B was set
$(info B is $(B))

# immediate -- C is expanded in order to be printed
# This prints "bar", because the reference to A was expanded back
# when C was set
$(info C is $(C))

lg> What are the advantages (dis-advantages) of immediate (deferred)
lg> assignment?

A recursive variable (expansion is deferred) will have to be expanded
every time the variable is referenced. Any variables in the value
expand to their CURRENT values, not what they were when the simple
variable was assigned.

A simple variable (expansion is immediate) is expanded once when the
variable is assigned, and doesn't have to be expanded again when it's
used. Any variables in the value are expanded at that time.

--
-------------------------------------------------------------------------------
Paul D. Smith Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
reply via email to

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