[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: x:sin() vs. math.sin(x)
- From: John Belmonte <jvb@...>
- Date: Sun, 21 Apr 2002 03:07:46 +0900
Someone turned your favorite sweatshirt inside out. So will you
suddenly hate it, or realize that it's your favorite sweatshirt turned
inside out?
If I have
x:sin()
then certainly I can make a functional version with ease:
function math.sin(x) return x:sin() end
Going further, I can mess with math's metatable and make this automatic,
so that a call to any function
math.foo(x, ...)
is routed to
x:foo(...)
(Hmm, is this is the opposite of the syntactic sugar for methods?)
So you can have both ways, and still allow adventurous folks to
implement big numbers or even fixed point numbers that behave just like
the built-in number type.
-John
--
OpenPGP encrypted mail welcome.