lua-users home
lua-l archive

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


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--