bug-make
[Top][All Lists]
Advanced

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

New append operators (was: Re: New conditional assignment facility)


From: Paul Smith
Subject: New append operators (was: Re: New conditional assignment facility)
Date: Sun, 28 Jan 2024 17:41:00 -0500
User-agent: Evolution 3.50.3 (by Flathub.org)

On Mon, 2024-01-22 at 21:33 -0500, Dmitry Goncharov wrote:
> On Mon, Jan 22, 2024 at 8:16 AM Paul Smith <psmith@gnu.org> wrote:
> > I don't understand the point you are making about +!=.
> 
> If all new operators behave the same as +=, when the variable exists,
> then +!= is not needed, because +!= would do the same as +=$(shell
> ...).

They are not equivalent since if the variable is recursive the +!=
model would execute the shell script immediately, one time, and append
the result, while += $(shell ...) would re-run the shell script every
time the variable was expanded.

In addition to efficiency, it could be a noticeable behavior if the
shell script does something (like list files or obtain a date or
something) which might change between invocations.

In other words in this situation:

  foo = bar
  foo +!= echo baz

then the value of foo would be "bar baz", while in this situation:

  foo = bar
  foo += $(shell echo baz)

the value of foo would be "bar $(shell echo baz)".  Of course you can
rewrite it to be the equivalent, like this:

  foo = bar
  __foo := $(shell echo baz)
  foo += $(__foo)

here bar has a value of "bar $(__foo)": as long as __foo was not reset
then it would give the same result as +!=.

-- 
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




reply via email to

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