[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: defining swap
- From: Jonas Meyer <jonas.meyer@...>
- Date: Thu, 28 Oct 2004 16:12:13 +0200
Hi.
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:
tab={}
function TableSwap( a, b )
tab[ a ], tab[ b ] = tab[ b ], tab[ a ]
end
...
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
meyer@diku.dk