[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New conditional assignm ent facility
From: |
Paul Smith |
Subject: |
Re: New conditional assignm ent facility |
Date: |
Sat, 27 Jan 2024 16:13:54 -0500 |
User-agent: |
Evolution 3.50.3 (by Flathub.org) |
On Sat, 2024-01-27 at 15:52 -0500, rsbecker@nexbridge.com wrote:
> > I'm interested in peoples' opinions about which of these two
> > implementations they would feel to be more "intuitive" or
> > "correct". Also please consider issues of "action at a distance"
> > where a variable is assigned in one makefile and appended to in
> > some other makefile, potentially far away.
>
> Intuitive reading of this would seem that "bar=2 2 3" is better, as
> +:= should force complete resolution of the string applied to bar,
> not partial resolution of foo keeping an instance of $(foo) for
> resolution later.
Hm, maybe I'm just weird. Or maybe I chose a poor example.
What if the example was like this:
foo_ARGS = -a
bar_ARGS = -b
ARGS = $($@_ARGS) -x
all: foo bar
foo bar: ; cmd $(ARGS) $@
ARGS +:= $(shell gen-args)
where the "gen-args" program outputs "-z".
and now the value of ARGS would either be "$($@_ARGS) -x -z" using the
method I was suggesting, or it would be " -x -z" using the alternative
method where ARGS was converted into a simple variable.
So using the first method make would run:
cmd -a -x -z foo
cmd -b -x -z bar
and using the alternative method make would run:
cmd -x -z foo
cmd -x -z bar
Is it still more intuitive? Maybe the answer is "well, just don't do
that" :). Or maybe "+!=" could be used in this specific situation, but
you get the idea.
The problem is that when you write the assignment +:= it's not always
so simple to know what the side-effects might be because you don't know
what the current behavior of the variable is, and it might change in
the future. Of course, that's always a problem with makefiles.
--
Paul D. Smith <psmith@gnu.org> Find some GNU make tips at:
https://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist
- Re: New conditional assignment facility, (continued)
- Re: New conditional assignment facility, Paul Smith, 2024/01/21
- Re: New conditional assignment facility, Dmitry Goncharov, 2024/01/21
- Re: New conditional assignment facility, Paul Smith, 2024/01/22
- Re: New conditional assignment facility, Jouke Witteveen, 2024/01/22
- Re: New conditional assignment facility, Martin Dorey, 2024/01/22
- Re: New conditional assignment facility, Jouke Witteveen, 2024/01/22
- Re: New conditional assignment facility, Dmitry Goncharov, 2024/01/22
- New append operators (was: Re: New conditional assignment facility), Paul Smith, 2024/01/28
- Re: New conditional assignment facility, Paul Smith, 2024/01/27
- RE: New conditional assignm ent facility, rsbecker, 2024/01/27
- Re: New conditional assignm ent facility,
Paul Smith <=
- RE: New conditional assignm ent facility, rsbecker, 2024/01/27
- New append operators (was: Re: New conditional assignment facility), Paul Smith, 2024/01/28
- RE: New append operators (was: Re: New conditional assignment facility), rsbecker, 2024/01/28
- Re: New append operators (was: Re: New conditional assignment facility), Paul Smith, 2024/01/28
- Re: New conditional assignm ent facility, Edward Welbourne, 2024/01/29
- RE: New conditional assignm ent facility, rsbecker, 2024/01/29
- Re: New conditional assignment facility, Edward Welbourne, 2024/01/29
Re: New conditional assignment facility, Alejandro Colomar, 2024/01/11