[Top][All Lists]

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

Re: [RFC] Scoped variables, supercharged

From: Jouke Witteveen
Subject: Re: [RFC] Scoped variables, supercharged
Date: Thu, 26 Dec 2019 21:24:36 +0100

On Thu, Dec 26, 2019 at 6:13 PM <address@hidden> wrote:
> Jouke Witteveen writes:
>  > I would like make to have scoped variables. Here, I will propose an
>  > implementation of them. This implementation is currently without tests and
>  > documentation. Hopefully, the proposal is acceptable and I can add the
>  > tests and documentation.
>  >
>  > Consider a situation in which we have macros F and G, and some variable X,
>  > and our makefile includes:
>  >
>  >   $(call F,$(call G,$(X)),$(call G,$(X)))
>  Your proposal has the potential to create variables that would have
>  scope local to a single invocation of a user-defined function, but it
>  wouldn't provide scoping to Make-proper.  For that reason alone, I
>  would suggest narrowing down the naming of the feature.  Perhaps
>  something like:

What other meaning of 'scoping to Make-proper' do you have in mind? I
fail to see a scoping scenario that is not covered by my $(let)

>    Function local variables

Except that it has nothing to do with functions. Instead of the call
statements in my example, you can think of any long statement that
uses the same substatement (that has no side-effects) multiple times.

>  Have you considered how this might affect target- and
>  pattern-specific variables?
>  What would the affect be of a local variable overriding the name of a
>  global variable?

Global variables are shielded in the same way that $(call ...) shields
$0, $1, $2, ... in nested invocations.

>  Finally, have you taken a look at the so-called Gnu Make Standard
>  Library (GMSL)?  The implementation of dictionaries in that piece of
>  software reduces the need to introduce changes to Gnu Make to support
>  variable scoping -- but I accept that might be a controversial view.

I am aware of that library. I'd say it would benefit greatly from the
addition of my $(let) built-in to make.

reply via email to

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