[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about immediate and deferred variable assignment in GNU make
From: |
Paul D. Smith |
Subject: |
Re: about immediate and deferred variable assignment in GNU make |
Date: |
Wed, 26 Apr 2006 10:15:54 -0400 |
%% Lin George <address@hidden> 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 <address@hidden> 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
Re: about immediate and deferred variable assignment in GNU make, Lin George, 2006/04/26
- Re: about immediate and deferred variable assignment in GNU make, Paul D. Smith, 2006/04/26
- Re: about immediate and deferred variable assignment in GNU make, Lin George, 2006/04/26
- Re: about immediate and deferred variable assignment in GNU make, Paul D. Smith, 2006/04/27
- Re: about immediate and deferred variable assignment in GNU make, Lin George, 2006/04/28
- Re: about immediate and deferred variable assignment in GNU make, Paul D. Smith, 2006/04/28