lua-users home
lua-l archive

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


What does it mean when I call a c function that pushes userdata
multiple times, but that every reference points to the last value.

Userdata pointers don't seem to be store like a regular number.
With the below code, I can make newThing push a long instead
and everything will work as expected.

a = newThing(1,2,3)
b = newThing(3,4,5)
c = newThing(6,7,8) -- newThing simply pushes a new userdata

doSomething(a) -- uses c
doSomething(b) -- uses c
doSomething(c) -- uses c

I am just trying to get the hang of userdata as objects.
What am I doing wrong? Is there a tutorial on implementing
multiple object instances of a single class somewhere?

Should I consider 4.1? Would it make a worthwhile difference
for someone implementing simple object instances?