lua-users home
lua-l archive

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


Eike Decker wrote:
Hi

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
or
x,y,z /= len,len,len

instead of

x,y,z = x + vx, y + vy, z + vz
or
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)?

greetings
Eike Decker


+= 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 like this:

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

etc etc..