bug-make
[Top][All Lists]
Advanced

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

Re: New conditional assignment facility


From: Edward Welbourne
Subject: Re: New conditional assignment facility
Date: Mon, 29 Jan 2024 09:52:15 +0000

Paul Smith (27 January 2024 21:32) 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.

A naive C-programmer approach starts from

  x += y

in C meaning the same as

  x = x + y

This leads to an "intuitive" approach being to have

  x +:= y

mean

  x := $(x) y

in make, with analogous statements for each of the other increment
operators.  IIRC, that runs into trouble because plain x += y has
already been implemented and preserves the type of x, rather than
revising it to be recursive evaluation.  Then again,

  x = $(x) y

would be problematic in any case, since $(x) would then be an infinite
recursion.  That's an argument for += to get special treatment.

Perhaps it would be useful to enumerate the other types of assignment
(I'm unfamiliar with the ones beyond = and := myself) and describe what
putting a $(x) to the right of each (as replacement for a + before it,
when x is the left-hand operand) would do and what problems each would
pose.  That might give some clarity to the options.  In particular,
given that it's immediately clear what

  x := $(x) y

does, having +:= do the same thing is semi-redundant.

        Eddy.



reply via email to

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