help-make
[Top][All Lists]
Advanced

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

Re: What should an $(add) function look like?


From: Reinier Post
Subject: Re: What should an $(add) function look like?
Date: Sat, 31 Oct 2015 21:10:43 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat Oct 31 19:25:40 2015, address@hidden (Tim Murphy) wrote:
> Hi,
> 
> I'm implementing some new GNU make functions as loadable modules and I just
> wondered if anyone had thoughts about how it would be best to implement
> some of them.

[...]

> As I was implementing this, however, I thought: why not add a list of
> numbers?
> 
> e.g.
> $(add 1 2  3 -1 1)

I like this, to me it seems to fit more naturally with existing
functions.  As the name I would use 'sum': 'add' suggests only
twp arguments and suggests that one of them is modified,
neither of which is the case.

> This might turn out to be much more generally useful.   e.g. adding a list
> of file sizes together or something similar.  Is this a good idea?

It would be even more general to add higher-order functions (map, fold).
Don't create a bag of functions, create a Lisp.

> I also think that some numeric comparison functions might be handy e.g.
> $(gt x,y) and $(lt x,y) plus the other obvious variations. Is there
> anything else worth putting in?

To be honest, I'm conflicted about functions being present at all.
Originally, make was on an equal footing with the shell: it just
created the execution logic, with all the real work being delegated
to executables.  It makes sense to add computing power on the values
of variables, like bash did, but I'd avoid adding all kinds of
specific functions just because they are useful - that will become
ugly, you'd never stop adding more functions, just like it happened
in Perl 4 and PHP.  It seems more useful to focus on general,
extension mechanisms that would allow makefile writers to easily
add their own functionality; for instance (just thinking out loud),
a way could be added to directly call the main() function
of arbitrary compiled executables so as to avoid the fork().

> Regards,
> 
> Tim

-- 
Reinier Post



reply via email to

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