lua-users home
lua-l archive

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


Rici Lake wrote:
For what it's worth, I still think min and max should be primitives rather than part of the math package. They are perfectly well defined for anything for which < or <= is a total-ordering, or something close to a total ordering. [2]

I don't disagree with you, but what are the use-cases? I mean, are they that much used that they need a special treatment over other math/string functions?

I don't use min and max much in my programs, that's why I ask. Of course, I don't much pow/^ either... But perhaps I am either missing opportunities, or I am just not in the "right" programming domain.

[1] I ran into this in the Allegro faq <http://alleg.sourceforge.net/faq.html> this morning, and it charmed me enough that I reproduce it here:

Q: Why is it considered good coding practice to define PI as a constant, rather than just using the value 3.141592 in my code?

A: It simplifies the maintenance of your program, in case the value of PI ever needs to be changed. Also it will make your program more portable to other compilers that use different values of PI.

Very nice, they have thought of everything, including compilers using PI as 22/7 or those living near black holes or on a non-euclidian world.

I would have written that it is more terse than giving the numerical values, and less prone to errors, but it is too practical...

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --