Talk:EraseTable

Scope
Would this not just delete the contents of the locally scoped "t" leaving the original table untouched? Egingell 02:20, 18 July 2007 (UTC)


 * Table pass by reference 03:00, 18 July 2007 (UTC)
 * Good to know. :) Egingell 06:30, 18 July 2007 (UTC)

wipe
Isn't there a Blizzard-provided function that does this now (added in 3.0)? E.g., wipe(tab) It doesn't seem to be documented on WoWWiki yet, but I'm almost positive this is the case. I'll check when I get the chance, but thought another user here would have the answer before I can. -- Tuhljin (talk) 02:57, 4 December 2008 (UTC)
 * Yes, there is. It returns the new table.

tab = wipe(tab)

I'm still learning Lua so I apologize if this is a stupid question, but doesn't Lua use reference counting or something similar to track dead objects (garbage)? Rather than looping through an entire table and setting each element to nil, couldn't you just set the table itself to nil instead? I'm assuming that if nothing else has references to the elements in this table, it will be collected next time the garbage collector is run. Also, wouldn't this wipe function you're referring to basically have the exact same effect as the following? v = {x=1, y=1, z=0} -- create a table that represents a vector v = {} -- now create a new empty table and assign it to t, leaving no references to the old vector

Am I not understanding something here about the way Lua's garbage collector works? Functions like wipe and EraseTable just seem unnecessary code that ultimately does nothing. Wouldn't Lua have come with a function like this if it were actually needed? o.O Please clarify if I'm wrong here. Thanks! --Spynesso (talk) 05:01, 27 April 2009 (UTC)

More Efficient
Would think wipe(t) would be more effective.

--MichaelLundRasmussen (talk) 13:10, December 30, 2009 (UTC)
 * wipe was added long after this user function was added to the Wiki.