lua-users home
lua-l archive

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

On Mon, Oct 18, 2010 at 1:56 PM, Francesco Abbate
<> wrote:
> 2010/10/18 Javier Guerra Giraldez <>:
>> i can't think of an example where:
>> - A can be created before B
>> - but A depends on B  (how did it exist before B, then?)
>> - you have to destroy A before B
> For example A is a plot and B is a line or a graphical elements. You
> create first the plot wichh is initially empty and then you add
> graphical elements like lines or circles or something else. Once you
> have added an element to the plot this latter store a *reference* to
> the element and it is therefore important to ensure that B (the
> element) is not collected as far as A (the plot) exists.
> But I can make to you a simple Lua example:
> A = {}
> B = { 'hello world' }
> A[1] = B

So, what happens in this case in C++?

Plot *p = new Plot();
Line *l = new Line();
delete p;

Is Line l invalid?  When it's added to the Plot does Plot take
ownership?  Increment a reference count?  Seems like you have the same
problems in C++ as you would with Lua.