On 2018-08-07 23:31, Mark Wieder via use-livecode wrote:
On 08/07/2018 02:21 PM, Mark Waddingham via use-livecode wrote:
However, the engine treats arrays which have all integer (string) keys starting at one and are dense (i.e. the number of elements == max(all keys)) from ones that aren't.

There should have been a 'differently' in there.

Not sure how to interpret that. If I create

repeat with i=1 to 10
  put i into tArray[i]
end repeat

to make a 'special' array and then
delete variable tArray[3]

does that take it out of the 'special' category?

Yes - unless the array's first key is 1, and it then has all integer keys up to and including its number of elements then it is not considered a sequence array.

i.e. [1], [3], [5] - not a sequence
     [2], [3], [4] - not a sequence
     [1], [2], [3] - a sequence

The specialness is quite restricted - however such arrays:

1) are ordered when used with 'repeat for each element' *not* repeat for each key:

       repeat for each element tElement in tSeqArray
         ... tElement will first be [1], then [2], ... then [n] ...
       end repeat

  2) can be used as a sequence of keys to traverse in [] - e.g.

      put tArray[tSeqArray] == tArray[tSeqArray[1]]...[tSeqArray[2]]

3) admit a more efficient representation in arrayEncode - they are encoded as 'sequences', so the engine does not emit the keys - instead it just emits a sequence of values [1], [2], ..., [n]... Which saves some space.

Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to