Clearing local variables

Mark Waddingham 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> 
> wrote:
> 
>> 
>> From 7.0 onwards, this causes no problem as the engine takes a 'copy' 
>> of
>> the target variable at the start of the loop. (Note you only pay for 
>> that
>> 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 
>> W
> 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 
>> will
>> not cause a script error, but will almost certainly produce unexpected
>> results.

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 
that).

Warmest Regards,

Mark.

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



More information about the use-livecode mailing list