Re: FFI: __gc for non-structs

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 25 May 2012 19:25:33 -0500

On Fri, May 25, 2012 at 7:24 PM, Daurnimator <quae@xxxxxxxxxxxxxxx> wrote:
> Hi
>
> I'm wondering what the best way to have a garbage collection callback for
> objects that are simply ints (eg, file descriptors)
> To my chargrin, tables don't support __gc: so I can't pack values into one.
> The only method I see is using dummy structs or newproxy...
>
> Please advise :)
>
> D

A dummy struct sounds like the best solution to me. It's called a
"boxed" value when you do it that way, and you do it specifically for
reasons like this where you need stronger typing.

/s/ Adam

Other related posts: