lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


That makes it work perfectly, and thank you for the explanation.  I've
learned to avoid global variables (non-function variables) by default,
but didn't really know of the interaction of upvalues with global
functions (and coroutines).  Now off to continue writing my game ;)

Thanks again!
  Ian

On Mon, Jun 20, 2011 at 2:46 AM, Lorenzo Donati
<lorenzodonatibz@interfree.it> wrote:
> On 20/06/2011 7.13, Lorenzo Donati wrote:
>
> [replying to myself to amend a copy/paste mistake]
>
> The last section should read (added emphasis on the corrected word):
>
>> When you resume the *FIRST* coroutine for the second time (third call to
>> resume), its execution resumes where it yielded (in the while loop), but
>> then you call check (global), which retains the closure created _in the
>> second coroutine_ (with ITS obj upvalue, i.e. that created in the second
>> call to resume), so "check" prints out the data for the "obj" argument
>> of the second coroutine.
>>
>> -- Lorenzo
>>