[bug #51286] Support for additional local make variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #51286] Support for additional local make variables

anonymous
URL:
  <http://savannah.gnu.org/bugs/?51286>

                 Summary: Support for additional local make variables
                 Project: make
            Submitted by: elfring
            Submitted on: Wed 21 Jun 2017 07:00:14 PM CEST
                Severity: 3 - Normal
              Item Group: Enhancement
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.2.1
        Operating System: Any
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

The documentation
<https://www.gnu.org/software/make/manual/html_node/Call-Function.html>
contains the following information:
“…
The call function can be nested. Each recursive invocation gets its own local
values for $(1), etc. that mask the values of higher-level call.
…”

The creation of temporary variables (which are just numbered) is already
supported by this programming interface for function parameters.
I would like to use similar functionality in the way that make variables can
be adjusted within an customised scope so that variables in other scopes can
be left untouched.
With which additional function calls can corresponding variable scopes be
managed?




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51286>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

[bug #51286] Support for additional local make variables

anonymous
Follow-up Comment #1, bug #51286 (project make):

If the value you are trying to assign to a variable is guaranteed to contain
no spaces, you could use
  $(foreach var,<val>,<...>)
but that is a bit of a hack of course.

More complete lexical scoping was proposed on the mailing list
(https://lists.gnu.org/archive/html/bug-make/2019-12/msg00017.html) in the
form of let expressions
  $(let <var>,<val>,<...>)
but Paul Smith expressed his concern that let expressions may be to foreign to
the audience of make and that they do not fit the overall design of make
nicely.

I have attached the working prototype for implementing let expressions, which
lack documentation. Essentially, each word of <val> is assigned to each
variable name in <var>, where the last variable name gets all remaining words
in <val>. If there are more words in <var> than in <val>, the corresponding
variables will be empty.

(file #48701)
    _______________________________________________________

Additional Item Attachment:

File name: let-function.patch             Size:2 KB
    <https://savannah.gnu.org/file/let-function.patch?file_id=48701>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?51286>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #51286] Support for additional local make variables

anonymous
Follow-up Comment #3, bug #51286 (project make):

> Dit I?

Wow, indeed, my memory is quite far off. Sorry!

I was thinking of an exchange regarding a request for renaming by thutt. Your
only expressed concern was that the behavior of let bindings might not be
clear to people not familiar with languages that have such bindings, i.e.

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

My remark on "not fitting the design" was probably my mind trying to think of
good reasons to keep $(let) out of make. It may have been my own concern more
than yours ;-).

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?51286>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/