lua-users home
lua-l archive

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


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".

On Tue, Sep 23, 2008 at 11:47 AM, Javier Guerra <javier@guerrag.com> wrote:
On Tue, Sep 23, 2008 at 12:50 PM, Matthew Armstrong
<turkeypotpie@gmail.com> wrote:
>>>>
> So, if I could have this line:
> b = a.b
> ... do a copy instead of a reference assignment, I'd be ok.  There also
> might be some other ways to solve this problem, so I'm not hung up on using
> this method.

I'd guess the easiest way is to add a copy() method to your objects

--
Javier