Page 1 of 1

CreateList Modifying Items.

Posted: Fri Dec 12, 2025 5:09 pm
by Bugala
It says in the CreateList description:

"The disadvantage is that adding or removing items may only be done via InsertItem() and RemoveItem(). You must not add or remove items from optimized lists by modifying the table directly. It's necessary to use the functions mentioned above. "

But is this considered modifying the list (Referring to line Temp[40][1].a = 5):

Code: Select all

temp = CreateList()

For n=0 To 100
	InsertItem(Temp, {[0] = { a=n },
			  [1] = { a=n+2 }
			  }, n)
Next

Temp[40][1].a = 5
DebugPrint(Temp[40][1].a)
or is it only when I concretely remove an item from the list it is considered modifying the list?

Also, can the CreateList then contain any kind of Items, as in could I mix Functions, Numbers, Strings, or Subtables with different configurations, like:

Code: Select all

Function MyPrint()
   Debugprint("Hello World")
EndFunction

Temp = CreateList()
Table1 = { [0] = {a=1},
                         [1] = {b=2},
                         c = 3}
Table2 = { [2] = {a=4},
               b = 5}
Func = MyPrint
InsertItem(Temp, Table1)
InsertItem(Temp, Table2)
InsertItem(Temp, Func)
InsertItem(Temp, "string")
InsertItem(Temp, 10)
For at least when doing this, it doesnt crash. But do I lose the speed benefit or something, doing this way?

Re: CreateList Modifying Items.

Posted: Sat Dec 13, 2025 12:05 am
by Flinx
I think the key point is that Temp is a list with integer indexes, which can be seen in

Code: Select all

ForEach(Temp, DebugPrint)
What the list contains as elements should not matter.

Re: CreateList Modifying Items.

Posted: Sun Dec 14, 2025 5:46 pm
by airsoftsoftwair
Bugala wrote: Fri Dec 12, 2025 5:09 pm But is this considered modifying the list (Referring to line Temp[40][1].a = 5):
No, the doc clearly says that the only modification that is forbidden is adding or removing items without using functions from the table library. Just modifying the values of existing items is perfectly allowed. The only thing that's not allowed with optimized lists is adding or removing items manually without using table library functions.