bug-make
[Top][All Lists]
Advanced

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

Re: Idea: Allow $(name ...) as an abbrevation of $(call name ....)


From: Tim Murphy
Subject: Re: Idea: Allow $(name ...) as an abbrevation of $(call name ....)
Date: Thu, 13 Jun 2019 18:18:15 +0100

builtin functions can check their arguments to some extent. Interesting to wonder if user defined ones can.
we don't even have $(equals) or a way to know the number of arguments that were supplied or any mathematical operations with which to compare. So when something is called wongly it charges on to the end, evaluating blindly to who knows what and we can spend hours trying to tease out the cause of a missing compiler option .... but.....we are focused on the saving of a tiny bit of typing.

.....

Regards,

Tim

On Tue, 11 Jun 2019 at 14:09, David A. Wheeler <address@hidden> wrote:
On Tue, 11 Jun 2019 14:09:42 +0900, Masahiro Yamada <address@hidden> wrote:
> If we drop the compatibility like Python 3,
> We could fix our regrets ...

The Python3 transition was horrific,
and is a textbook case of how to *not* handle a transition.
It's not that Python3 is bad (I use it), but its transition
was handled very badly.

Backwards compatibility matters *greatly*.

> I am just interested in this topic because
> I implemented a similar language for Kconfig some time ago.
> (Kconfig is a configuration system for Linux Kernel).

I didn't realize Kconfig had these features.
Thanks for noting it, we should certainly try to learn from it.

> I wish the function call were:
>  $(func,arg1,arg2,arg3)
> instead of
>  $(func arg1,arg2,arg3)
> In Make, the function name and the first argument are separated
> by at least one whitespace.
> Then, all leading whitespaces are trimmed from the first argument.
>
> This means, we cannot pass spaces to the first argument
> (at least in a straightforward way).
...
> [1] Omit $(call ...) for user-defined function.
>    Built-in functions and user-defined functions
>    are called in the same way:
>     $(func,arg1,arg2,arg3)
> [2] Use a comma for every separator, and do not trim spaces at all.
>     I wanted to avoid gotchas when we pass spaces to the first argument.
...
> 'shell' is a built-in function.
> Only the difference is that it uses a comma instead of a space.

Interesting.  I see the argument for it!

I have the opposite problem: I usually do *NOT*
want to pass leading & trailing spaces in my arguments,
and so I keep having to $(strip ...) my arguments in functions.
Make's insistence on including spaces in each argument
also makes it difficult to break up long lines;
I can't easily have a "parameter on each line" like many languages
because the whitespace will be in the parameter.
That suggests that maybe a variant would be helpful
to automatically strip the parameters before calling.

So thinking out loud, I can see three options for
adding user-defined direct calls:
1. $(name arg1,arg2,...): Equivalent to
   $(call name,$(strip-leading-space arg1),arg2,...).
   This is my original proposal.
   The advantage of this syntax is that it's consistent with existing
   function calls, which many people know.
   Oddly, there's no obvious Make $(....) function built-in that does
   strip-leading-space (maybe there should be).
2. $(name,arg1,arg2,...): Equivalent to $(call name,arg1,arg2,...).
   This retains all leading/trailing whitespace and is compatible
    with Kconfig syntax (slightly simplifying transfers between them).
   "name" can be user-defined or a built-in.
3. $(name;arg1;arg2;...): Equivalent to
   $(call name,$(strip arg1),$(strip arg2),...).
   This would make it easy to add space after the parameter separator
   (like people do in many other languages) and break lines
   between parameters when the parameter set is long.
   It would also simplify passing arguments containing commas.

I would be happy if all 3 were implemented, really; they all have
their own trade-offs.  At least #1 or #2 should be implemented.

--- David A. Wheeler
_______________________________________________
Bug-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-make

reply via email to

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