Clearing local variables
mark at livecode.com
Thu Apr 28 11:47:15 EDT 2016
On 2016-04-28 03:31, Kay C Lan wrote:
> If you do not understand what isn't 'variable' and what really gets
> at each iteration for each style of repeat then you are likely to see
> unexpected results. On the other hand, if do understand what is really
> going on, then you can modify x to your advantage in either case. As
> tVar in the 'repeat for each' case, I believe Mark Waddingham has
> that although your scripts might currently work if you modify tVar mid
> repeat, LC is NOT guaranteed to behave the same way in the future.
Prior to 7.0 modifying the target variable inside a repeat for each
would cause undefined behavior. i.e.
repeat for each item tItem in tList
delete any char of tList
Was always a really bad idea.
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).
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the Use-livecode