lua-users home
lua-l archive

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


I'm having trouble defining a method similar to std::swap from c++, as
it seems all parameters are passed by-value.
I need to swap two userdata objects, defined via luabind. Each of the
objects contain one pointer.. so I really just want to swap the
pointers contained inside the objects

Is there any way to solve this? My best bet, so far, is using a global
table something like this:

function TableSwap( a, b )
  tab[ a ], tab[ b ] = tab[ b ], tab[ a ]

tab[ 0 ] = foo
tab[ 1 ] = bar
TableSwap( 0, 1 )

But it seems cumbersome, and I was hoping there was some other way to solve it.

Jonas Meyer