Stumped on Order of execution (yeah, another :removeSelf() question)

Wow, interesting. Great blog post. So am I correct to understand that newPanel in @richard9’s post #8 will remain as a table after the transition is completed (even though it won’t be holding the display group object) until its reference to the makePanel function is manually nil’ed, or until it is garbage collected?

Naomi [import]uid: 67217 topic_id: 32789 reply_id: 130476[/import]

Here you go

local group = display.newGroup()  
  
function group:close()  
 local function clearGroup()  
 group:removeSelf()  
 group = nil  
  
 print( group )  
 end  
  
 -- Slide out the object  
 group.transition = transition.to(group, { y = group.y + group.height, time = 200, onComplete = clearGroup } )  
end  
  
local img = display.newRect( 0, 0, 200, 200 )  
group:insert( img )  
  
group:close()  
  
timer.performWithDelay( 2000, function() print( group ) end )  

Some reading:

http://www.coronalabs.com/blog/2011/07/19/local-variables-lua/
http://stackoverflow.com/questions/8392168/lua-metatable-class-destructor
[import]uid: 84637 topic_id: 32789 reply_id: 130471[/import]

Wow, interesting. Great blog post. So am I correct to understand that newPanel in @richard9’s post #8 will remain as a table after the transition is completed (even though it won’t be holding the display group object) until its reference to the makePanel function is manually nil’ed, or until it is garbage collected?

Naomi [import]uid: 67217 topic_id: 32789 reply_id: 130476[/import]

Honestly don’t understand the second link at all; have no idea how a[{}] is valid. I imagine that’s just mumbo-jumbo for the career programmers.

The second link is also a bit verbose but I can sorta understand what’s going on. It sounds like what is being said is that you have to do both -> internally nil the group from within the function AND nil the external variable for it, as the the former is the only way to destroy the contents and the latter is the only way to destroy the reference? [import]uid: 41884 topic_id: 32789 reply_id: 130550[/import]

Honestly don’t understand the second link at all; have no idea how a[{}] is valid. I imagine that’s just mumbo-jumbo for the career programmers.

The second link is also a bit verbose but I can sorta understand what’s going on. It sounds like what is being said is that you have to do both -> internally nil the group from within the function AND nil the external variable for it, as the the former is the only way to destroy the contents and the latter is the only way to destroy the reference? [import]uid: 41884 topic_id: 32789 reply_id: 130550[/import]