View Single Post
06-20-12, 05:08 PM   #19
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Billtopia View Post
myTable = { {unpack( myTable )}, ... }
If your original table looks like this:
Code:
myTable = { "one", "two", "three" }
#myTable == 3

And you add the values "four" and "five" on the end:
Code:
tAppend(myTable, "four", "five")
Then your code is actually doing this:
Code:
myTable = { { unpack( { "one", "two", "three" } ) }, "four", "five" }
which simplifies to this:
Code:
myTable = { { "one", "two", "three" }, "four", "five" }
#myTable == 3

You've just created a new table that still only has 3 values, and another new table containing the original three values. Now imagine what happens after you run that a couple of times:

Code:
myTable = {
	{
		{
			{
				{
					{
						"one",
						"two",
						"three",
					},
					"four",
					"five",
				},
				"six",
			},
			"seven",
			"eight",
			"nine",
		},
		"ten",
		"eleven",
	},
	"twelve",
}
Is that really a table structure you'd want to try to work with?

Plus, if you were to do anything like this, you would never be able to use local references to your table. Add together the ridiculously convoluted structure you see above, the unnecessary overhead of performing a global lookup every time you access your table, and the significant memory waste of creating two new tables and discarding one table every time you append anything, and this is just horribly inefficient and unusable code that you should never even consider using.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote