%% Lin George <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>          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


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to