Clearing local variables
mark at livecode.com
Fri Apr 29 17:17:52 CEST 2016
On 2016-04-29 04:30, Kay C Lan wrote:
> On Thu, Apr 28, 2016 at 11:47 PM, Mark Waddingham <mark at livecode.com>
>> From 7.0 onwards, this causes no problem as the engine takes a 'copy'
>> the target variable at the start of the loop. (Note you only pay for
>> copy when you mutate tList subsequently, and that mutation has no
>> effect on
>> the repeat for each loop being performed).
>> Oh, so if your repeat script works now in LC 7/8 it comes with a Mark
> guarantee that it'll work in the future. ;-) Cool!
> Does that mean the 'Important' note in the LC 8 Dictionary entry for
> 'repeat' isn't so Important any more?
> Important: In any of the for each loops, you should not change the
>> labelVariable or container in a statement inside the loop. Doing so
>> not cause a script error, but will almost certainly produce unexpected
Yes! That note should probably be replaced by one which says you can
modify the target variable in the loop, but it won't have an effect on
what is being repeated over. (I'm sure there's a better way to express
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the use-livecode