[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: Lua 5.3: Should min/max return a float, if it is given integer?**
**From**: Leo Razoumov <slonik.az@...>
**Date**: Thu, 19 Jun 2014 09:51:47 -0400

On 6/5/14, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-06-05 2:02 GMT+02:00 Hisham <h@hisham.hm>:
>> But the argument of having math.max and math.min preserve integers
>> (and their precision) has, in my opinion, a very strong case.
>> (Especially since math.max and math.min _are_ convenience functions
>> after all, so the "roll your own" answer does not apply.)
>
> Maybe there is a case for taking them out of the math library
> and putting them back into global, with `max(a,b)` meaning
> exactly the same as "(b>a) and b or a" so that they will apply
> to anything, particularly strings.
>
This is a very sensible suggestion. min/max operations can be defined
for any objects that have the notion of ordering and by no means
should be limited to just numbers. Any user object with reasonably
defined __lt() metamethod should work with min/max functions.
--Leo--

**References**:
**Lua 5.3: Should min/max return a float, if it is given integer?, ***Andrew Starks*
**Re: Lua 5.3: Should min/max return a float, if it is given integer?, ***Dirk Laurie*
**Re: Lua 5.3: Should min/max return a float, if it is given integer?, ***Andrew Starks*
**Re: Lua 5.3: Should min/max return a float, if it is given integer?, ***Hisham*
**Re: Lua 5.3: Should min/max return a float, if it is given integer?, ***Dirk Laurie*