[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: New conditional assignm ent facility
From: |
rsbecker |
Subject: |
RE: New conditional assignm ent facility |
Date: |
Sat, 27 Jan 2024 15:52:37 -0500 |
On Saturday, January 27, 2024 3:33 PM, Paul Smith wrote:
>On Mon, 2024-01-22 at 08:15 -0500, Paul Smith wrote:
>> Let's step back and I'll try to think more clearly about this.
>
>Sorry for the delay in replying.
>
>I can see that I was thinking about this one way but there's another way to
>look at it
>that I didn't think of. We are talking only about
>(a) append operators _other than_ +=, and (b) situations where the variable
>already
>has a value when the append operator is parsed.
>
>In all cases we would expand the right-hand side of the variable according to
>the
>assignment operator: e.g., if it were +:= we would immediately expand the RHS.
>
>My proposal was to keep the type of variable (recursive vs. simple) the same
>and
>then "fix up" the result of the RHS so it could be appended in a correct way.
>In this
>conception the operator applies ONLY to the RHS value, and will set the type
>of the
>variable only if the variable doesn't already exist, as a side-effect.
>
>The other way to think about it is that the assignment operator overrides the
>type
>of the variable as well: we would re-evaluate the LHS value then append the
>RHS.
>E.g., if it were +:= we would immediately expand the RHS as well and change the
>type of simple. In this conception the operator resets the type of the
>variable as its
>primary function, not just as a side-effect, and modifies not just the RHS
>value but
>also (possibly) the LHS value as well.
>
>An example to make this clearer:
>
>Given:
>
> foo = 1
> bar = $(foo)
> foo = 2
> bar +:= $(foo)
> foo = 3
> bar += $(foo)
>
> $(info bar=$(bar))
>
>In my original version, the result would be that "bar" is a recursive variable
>with the
>value "$(foo) 2 $(foo)" and the output of the info function would be "bar=3 2
>3".
>
>In the alternative version, the result would be that "bar" is a simple
>variable with the
>value "2 2 3" and the output of the info function would obviously be "bar=2 2
>3".
>
>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.
>
>
>This discussion has really helped me crystallize the differences and should
>make the
>resulting documentation, if/when it's written, much more clear so I definitely
>appreciate it!
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.
Just my $0.02.
Randall
- Re: New conditional assignment facility, (continued)
- Re: New conditional assignment facility, Dmitry Goncharov, 2024/01/20
- 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 <=
- Re: New conditional assignm ent facility, Paul Smith, 2024/01/27
- 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