[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_setuservalue() - what is it for?
- From: Daurnimator <quae@...>
- Date: Fri, 21 Aug 2015 11:53:05 +1000
On 21 August 2015 at 09:27, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> Apologies for this very basic question. What is the purpose (i.e. use
> case) of the lua_setuservalue() api?
To tie other lua values to a userdata.
Some use cases:
- have a simple reference to the parent object of a userdata
- to keep lua values for a userdata (e.g. a callback)
e.g. I have an open PR to luapgsql that uses a uservalue to keep a
reference to the lua FILE object you pass:
https://github.com/mbalmer/luapgsql/pull/24/files