[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: New operators?
- From: Stefan Sandberg <keffo.sandberg@...>
- Date: Wed, 11 Apr 2007 18:35:59 +0200
Eike Decker wrote:
I am carrying this in my mind for some time now and I guess, I am not alone:
What about a few new operators?
I think most people with a C/C++ background are missing the += *= etc operators
- and in my opinion these are really useful.
I have quite alot of vectoroperations in my luacode and it would be really great
if I could write
x,y,z += vx,vy,vz
x,y,z /= len,len,len
x,y,z = x + vx, y + vy, z + vz
x,y,z = x / len, y / len, z / len
It can be easier read and understood and is less to write.
Are there any reasons that speak against such operators (btw., the # operator is
was a great addition to 5.1)?
+= operators aside, introducing a,b,c += d,e,f is just silly..
If you do lots of vector math in your app, you really should create some
vector magic for it, such as this, http://giger.robot9.net/pub/vector.html
It's reasonably fast, can be made faster, and allows you to do stuff
local a = vector:new( 1, 2, 3 )
local b = vector:new( 4, 5, 6 )
local c = a + b;
c = c + vector:new( 1,1,1 );