bug-make
[Top][All Lists]
Advanced

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

RE: [bug #17529] Variable set with $(shell date '+%Y%m%d-%H%M%S') change


From: Terry Jones
Subject: RE: [bug #17529] Variable set with $(shell date '+%Y%m%d-%H%M%S') changes mid-make
Date: Sat, 26 Aug 2006 16:02:40 +0200

Hi again Martin.

| No.  It might sound like that but that's definitely, definitely, definitely
| not what happens.  Deferred variables are expanded again every time they're
| used.  I thought perhaps I'd quoted the wrong part of the documentation
| because, reading it again, I think you're right that it isn't clear.
| Searching for "deferred" didn't find me any other, clearer part.  Perhaps a
| clarification patch would be in order.

OK, I'm with you now, and see how things work. I think the docs could be
clearer on this too. Currently they speak of or imply (to me) expansion in
the singular. I think it's worth saying something like "deferred variables
are expanded _each time_ they are encountered during the second phase (not
once at the start of the second phase)". It's probably worth giving an
example showing why this is important, and the example could use $(shell),
perhaps even with something that changes, as in my example.

I do find the behavior a bit surprising. Make is effectively storing the
_definition_ of the variable (not its value) in its symbol table, and then
each time the variable is used it looks up this definition and evals it to
get a value. I suppose that behavior is deliberate and useful somewhere
specific, but it feels quite counter-intuitive for a programmer (this one
at least).  The behavior is more like macro expansion than using a variable
where you expect to get the value of a variable (and that that value does
not change unless you the programmer change it).

I think it would be clearer to say that, as well as 2 phases of reading a
makefile, one of the following:

  A) that there are two kinds of variables: normal and macro; or

  B) that there are two kinds of expansion: variable value 'substitution'
  via := and on-demand macro 'expansion' / textual replacement via =

Another way of trying to put my finger on the confusing part is to say that
the current docs mix two things: they talk exclusively about 'variables'
(leading one to think that variable values are stored in a symbol table)
and about 'expansion' (used in the sense of macro expansion).

Enough words, I know. Thanks for clearing this up.

Regards,
Terry




reply via email to

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