lua-users home
lua-l archive

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


You certainly can use tags to overload the arithmetic operators. 

I think you should ask yourself the question: Is it more important for
vector accesses to be fast, or transform/operations on the vectors to be
fast. If the latter is true then I would look back a few emails (or I can
dig it up) for an email of mine which explained how to make a C data
structure look like a table to Lua. If the former is true, then just make
a Lua table, change it's tag, and setup some tag handlers to do the
math operations.


On Mon, Jun 22, 1998 at 02:26:29PM -0300, Nick.Trout@psygnosis.co.uk wrote:
> Hi I'm attempting to add a 3D vector class to Lua and I wondered if anyone
> had any thoughts on the matter. What would be the most efficient manner?
> (ie. fastest). Can I use tags to overload the arithmetic operators. eg.
> vec3= vec1 + vec2 ?
> 
> Be something like: struct _vector3 { float x,y,z; };

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net