Yeah, deli with a zero or negative index seems to just be ignored. Since those cases don't appear to be documented it's hard to say whether it's the intended behaviour or not--I'd prefer an error message telling me my index was out of range personally--but it seems like reasonable behaviour at least. Deli will normally reorder the array to eliminate any [nil] values in the middle and since lua arrays are 1-based it will re-order so the first element is at index 1.
In that context, deleting the element at index 0 or just ignoring it and doing nothing are functionally equivalent, at least as far as the other array handling functions are concerned: they all assume 1-based arrays so they'll never see the element at index 0 anyway.
You could always override the default deli with your own version which works on 0-based arrays but it'll use up tokens and probably be less efficient. Unless you really need 0-based arrays it's almost certainly not worth it and just easier to stick to 1-based arrays.
It seems like intended behaviour!
Array-like tables use continuous integer indices starting at 1. This is fundamental to the operation of add, all, #, deli, etc.
When 0 is used as index, it is treated the same any regular mapping index, like a string. It does not change the 1-based behaviours.
pal is the one exception that will consider index 0 to replace palette entry 0.
[Please log in to post a comment]