I don't mind a good discussion but please watch your language. Definitely if you make statements which are not solid.
1) your language:
It is not macroses but macros
You do not use WTF. Definitely not in a title.
Thanks. I was a little bit upset that I have to reinvent standard library. I've corrected errors.
2) the "must be a function"
The C89 standard you refer to is more commonly known as ANSI C. ANSI C was officially released in 1989. I have been programming in C from 1991 till 2000 for my living. In all those years I used a define for max. It is new to me that this must be a function. If you are sure that ANSI C states that max must be a function please tell me where this is stated.
The C99 is the newest version of C. The compiler used by the Arduino team is (like most other C compilers) not 100% compliant with C99. As far as I know there is no statement that max must be a function. Please state where it states min max and abs must be functions. Also refer to where it states all C compilers must comply to C99.
I didn't want to say that max must be a function accordingly to standard. Only abs must, in ANSI C too. I wanted to say that today in 2011, nearly in 2012 there is no need to put user right at the edge of a pit, even if you warn him. Look at this macro:
define sq(x) ((x)*(x))
It squares a variable. Why you would ever like to use it? If you have a single variable x it is easier and shorter to write x*x. But if you have a big statement which you would like to square it is very handy just to put it inside sq(). If sq was a function it would be computationally efficient too.
So if you see that using sq()would ease your life you nearly definitely going to make a mistake. This macro pushes user to a wrong way.
3) No macros but Inline
You state that these macros must be rewritten as inline. Inline is new in C99. It comes from C++. Inline is class related and on a AVR you do not want to have classes for something as basic as integers.
inline has nothing with classes. inline is just a hint for compiler that you would like to inline the function, nothing more. Using inlined function for integer does not convert them to classes.
4) why a macro?
A macro has a great advantage. That is, it works with any type that implements the methods you use. So you do not need a maxint maxlong maxstring.....
Actually this macro works only with different types of integers, float, double, pointers which can be implicitly converted to void*. If you have operator< defined for other type you are already using C++ and you can use templates which are much better then macro in this situation.
5) You are right there is a risk with macros
On the content you are right that
will result in MyNumber being 7 and not 6; This is however a design decision that has been taken a long time ago on very good ground by people that didn't know about Arduino because it simply didn't exist yet. So blaming Arduino is not the way to go. It has been like this for decades now. I feel no sense of urgency.
If you look at main arduino.cc page you ca read "It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments". Time has changed, programming languages has changed.This design decision was made "a long time ago on very good " old ground. Artists, designers, hobbyists do not need carefully documented well known rakes. 20 years ago it was the best solution but now we have more fool proof programming technologies. Which are still as efficient as old ones. They can be even more efficient in some cases.
6) overloaded functions from C++ std
I see no reason why you could not overload. You can use the #undef instructions if you want.
Thanks for the hint. I've did it for my building environment.