Arrays as first class citizens? Give them a passport! Arrays have rights too!
Need to check if they can be passed as parameters in setprop handlers - as in “set the beautiful_Colour [spellingArray] of my card to light-grey” Last time I checked not all first class citizens were equal. On Tue, 3 Apr 2018 at 08:51, Mark Waddingham via use-livecode < use-livecode@lists.runrev.com> wrote: > 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. > > -- > 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 > _______________________________________________ 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