[Top][All Lists]

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

Re: [RFC] Scoped variables, supercharged

From: Paul Smith
Subject: Re: [RFC] Scoped variables, supercharged
Date: Thu, 26 Dec 2019 16:52:04 -0500
User-agent: Evolution 3.34.1-2

On Thu, 2019-12-26 at 21:24 +0100, Jouke Witteveen wrote:
> >   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)
> proposal.

I believe thutt is thinking of creating new scopes in makefiles themselves,
not within a variable/function context, for example within included
makefiles or even within subsections of a particular makefile.

For example something where you could say:

   FOO = bar

   push scope
   local FOO = baz

   $(FOO): blah
   pop scope

   $(FOO): yuck

Of course if you wanted to write a bunch of define/endif stuff and use eval
you could use $(let ...) to do something like this but it can get pretty

That is a separate feature that wouldn't help you do what you want to do,
but that's probably why thutt suggests finding a more specific term.  In
Lisp, "let" creates "local bindings" not a new scope.  I'm not sure if that
is more or less clear for people not familiar with Lisp.

Here's another question: will this "do what you expect" if you invoke an
include within an eval within a let?  For example:

  $(let FOO BAR,,$(eval include myfile.mk))

will ensure that any "global" settings of FOO or BAR that are made inside
of myfile.mk are forgotten about afterwards?

What other sorts of tricks or issues could we get into using eval within
let, I wonder...

reply via email to

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