On Wed, 2025-09-10 at 23:38 +0200, Alejandro Colomar wrote:
> The reason I want to be able to undefine the variable name is to not
> need to come up with unique names in variables used within a recipe.
> That's why I immediately undefine it; to be able to reuse the name,
> making sure that old values are not used accidentally.

There are lots and lots of ways to do that.  You didn't really explain
clearly the problem you're trying to solve so I'll just give some
possible options:

You can use target-specific variables:

    all: foo := foo
    all: ; echo $(foo)

Or you can use constructed variable names (this is POSIX-complaint
even):

    all_foo := foo
    all: ; echo $($@_foo)

> And it may also improve performance.
> 
> Maybe we could have something like '.IMMEDIATRECIPEEXPANSION:'.

No, I do not think that's a good idea.  I don't really even see how it
could work.

For one thing, if you used something like this then automatic variables
would be useless, because they will always expand to either the empty
value or, at best, the wrong value.  Also, target-specific variables
cannot work.  Etc.

-- 
Paul D. Smith <psm...@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