help-make
[Top][All Lists]
Advanced

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

What should an $(add) function look like?


From: thutt
Subject: What should an $(add) function look like?
Date: Sat, 31 Oct 2015 14:02:35 -0700

Tim Murphy writes:
 > 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.
 > 
 > The one I'm looking at now is meant to be a way to add integers.
 > 
 > My major use would be to e.g. implement a counter so I'm mostly thinking of
 > being able to do COUNTER:=$(add $(COUNTER),1)
 > 
 > i.e. $(add x,y).   One might also implement a range function recursively
 > with this e.g. $(call range,1,10) returning "1 2 3 4 5 6 7 8 9"
 > 
 > I'm thinking that the numbers could be integers so $(add x,-1) would
 > decrement.
 > 
 > As I was implementing this, however, I thought: why not add a list of
 > numbers?
 > 
 > e.g.
 > $(add 1 2  3 -1 1)
 > 
 > 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?
 > 
 > 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?

 Perhaps your question is generalized about functions, but in case you
 are planning to implementat arithmetic, please know that the Gnu Make
 Standard Library (so named by the author) has arithmetic functions.


-- 
Irony: Visiting Karl Marx's grave, in a private cemetery, costs 4 Euros.



reply via email to

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