On 2018-04-02 21:28, J. Landman Gay via use-livecode wrote:
I found this:

Additionally the into clause has been added to all array set set
operations allowing commands such as:

  intersect tLeft with tRight into tResult

The operation of the commands is the same as the non-into form except
that tLeft does not have to be a variable, and the result of the
operation is placed into tResult rather than mutating tLeft.

So when is an array not a variable?

I must confess I found this quite an interesting question - as it speaks to the history of arrays in LiveCode.

Originally there were no arrays 'just' variables - a variable could hold a string, nothing else.

Then arrays were added, but they were not 'first class citizens' - so a perfectly reasonable mental model was that variables had been augmented so that they could be collections of named variables - each holding a string. (e.g. tFoo["a"], tFoo["b"] were both distinct variables, just with a convenient/indexable way of referencing them, and passing them around as a collection).

However, this changed when we added hierarchical arrays - i.e. being able to set an array as the value of an array key. The variable centric model then doesn't work so well - it is perhaps 'better' to think of arrays as values like strings. i.e. Arrays ceased to be tied to the notion of variable at all, and just became a 'value' which can be put into a variable.

Personally I think I always thought of arrays in LiveCode as values, but ones which had only been 'partially implemented' - there were lots of places prior to adding hierarchical arrays which wouldn't work with the existing notion of array, but had to be made to for hierarchical arrays to be in any way useful.

Another way to think about 'into' being added to intersect/union is that we've essentially added binary operators for array union and intersect:

  intersect tLeft with tRight into tResult

Does the same thing as a hypothetical 'intersect' binary operator:

  put tLeft intersect tRight into tResult

One could imagine a similar thing being added to the arithmetic commands:

  add tLeft to tRight into tResult

Would do nothing different from:

  put tLeft + tRight into tResult

This would just be a different way of expressing the same thing syntactically. (Note the 'into' form has not been added to the arithmetic commands, and there is no binary intersect/union operator - but perhaps both should be considered).

Warmest Regards,


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

use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription 

Reply via email to