bug-make
[Top][All Lists]
Advanced

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

Re: Tail call elimination


From: Jouke Witteveen
Subject: Re: Tail call elimination
Date: Mon, 18 May 2020 21:05:08 +0200

On Mon, May 18, 2020 at 8:50 PM Paul Smith <address@hidden> wrote:
>
> On Mon, 2020-05-11 at 16:32 -0500, Pete Dietl wrote:
> > I would like to know your thoughts about adding something like $(expr
> > ) to evaluate integer expressions and comparisons.
>
> I have no problem with some basic math facilities.  We already have
> functions like $(word ...), $(words ...), and $(wordlist ...), which
> sort of need math to be fully useful.

Each of these has an obvious 'output', which is not the case for
something like a comparison operator. This is also an objection
against $(eq) and $(not), which are hidden behind the EXPERIMENTAL
compilation flag.

> Adding in some simple comparison operators seems reasonable to me.
>
> >         $(if $(expr $(major1) <= $(major2) \
>
> I assume the missing ")," at the end of this was an oversight?

Note that version comparison can quickly get rather non-trivial. For
that reason, I would advise against implementing it in make. Instead,
simply use a dedicated program via $(shell). On my Arch Linux system,
I have a vercmp program tailored to this exact use case. Note that the
return value of a call to $(shell) is available in $(.SHELLSTATUS).

Otherwise, POSIX prescribes an expr command, so with:
expr = $(shell expr '$1')
you can already do $(call expr,2 * 3 + 5).

Regards,
- Jouke



reply via email to

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