FR - Arrays... Standard Array Functionality In LiveCode
Posted: Mon May 27, 2013 11:23 am
Can we discuss getting "standard array functionality" into LiveCode...?
In LiveCode, it seems that arrays behave differently than in many other programming languages. And so this may confuse new programmers and learners, as well as people that have used arrays before.
If you DELETE an myArray[2] in LiveCode, the LENGTH of myArray does not shrink. It seems that LiveCode uses "associative arrays." And each element is "associated" to its key. So deleting myArray[2] just leaves a "blank" spot in the second element of myArray. Whereas in most programming languages, deleting myArray[2] would shrink the number of elements in myArray, and myArray[3] would shift into the 2nd element.
This makes some very weird things happen, and forces us to INVENT the standard procedures that make arrays useful in the first place.
This is a shame. And I can't imagine how hairy things would get if you are using multidimensional arrays!
And if we are using LiveCode to teach kids how to code, they should know the proper use of an array!
If I am totally misunderstanding this, and the users in the following threads are misunderstanding proper array usage as well, please let me know. I just want LiveCode to be as simple to use as possible.
This is documented here:
http://forums.runrev.com/viewtopic.php?f=7&t=13116
http://www.mail-archive.com/use-livecod ... 12824.html
In LiveCode, it seems that arrays behave differently than in many other programming languages. And so this may confuse new programmers and learners, as well as people that have used arrays before.
If you DELETE an myArray[2] in LiveCode, the LENGTH of myArray does not shrink. It seems that LiveCode uses "associative arrays." And each element is "associated" to its key. So deleting myArray[2] just leaves a "blank" spot in the second element of myArray. Whereas in most programming languages, deleting myArray[2] would shrink the number of elements in myArray, and myArray[3] would shift into the 2nd element.
This makes some very weird things happen, and forces us to INVENT the standard procedures that make arrays useful in the first place.
This is a shame. And I can't imagine how hairy things would get if you are using multidimensional arrays!
And if we are using LiveCode to teach kids how to code, they should know the proper use of an array!
If I am totally misunderstanding this, and the users in the following threads are misunderstanding proper array usage as well, please let me know. I just want LiveCode to be as simple to use as possible.
This is documented here:
http://forums.runrev.com/viewtopic.php?f=7&t=13116
http://www.mail-archive.com/use-livecod ... 12824.html