[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Overriding assignment to do userdata copy instead of reference
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Wed, 24 Sep 2008 14:54:52 +0200
2008/9/23 Matthew Armstrong <turkeypotpie@gmail.com>:
> Adding a copy (or clone) method is entirely doable (I've actually done so
> already). The problem is, we have a rather large code base that depends on
> this type of code already:
>
> b = a.b
>
> Right now, a is never reclaimed, so we have a (bad) leak. If I fix the leak
> so 'a' is reclaimed, it will cause crashes all over the place, because b
> becomes invalid after collection.
>
> It would be very difficult to track down all these cases and replace a.b
> with a.b:clone(), or whatever. That's why I want to override the behavior
> and have it "just work".
Try the opposite approach, make a.b be a Lua reference, so that when a
is collected/deleted, you don't automatically delete its b sub-object.