[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: number, math, and metatable?**
**From**: "Thomas Jericke" <tjericke@...>
**Date**: Sat, 03 May 2014 11:38:02 +0200

-----Original Message-----
> From: "Dirk Laurie" <dirk.laurie@gmail.com>
> To: "Lua mailing list" <lua-l@lists.lua.org>
> Date: 03-05-2014 08:13
> Subject: Re: number, math, and metatable?
>
> 2014-05-03 0:55 GMT+02:00 Petite Abeille <petite.abeille@gmail.com>:
>
> > http://lua-users.org/lists/lua-l/2006-03/msg00691.html
> >
> > What about having the math library as the default metatable for number?
>
> I asked my two old friends Pro and Con to discuss it over a beer.
>
But your Pro should learn to make examples that help his case, your Con
already makes examples that work for his case. Here a nice Pro example:
local limtied = max(min(input, 1000), 100))
->
local limtied = input : min(1000) : max(100)
Well it is still confusing that the lower limit goes into max
and the upper into min, but you can't solve all problems at once.
Or with colon patch:
local sin, cos = math.sin, math.cos
local x,y = cos(60 : rad), sin(60 : rad)
-- Maybe confusing because you write what you want and not what you provide.
print('Angle=' .. math.atan2(y, x) : deg .. '°')
I am not so sure, if I would use it that often actually.
--
Thomas