lua-users home
lua-l archive

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

Now that I have coroutines up, i can pause them, resume them, create them, have many in parallel. Now, all i need is to learn Lua!

So my question is, once i spawn a coroutine, is its environment its own? For example:

i = 0
while i < 10 do
   print("Sleeping 1", i)

i = 0
while i < 10 do
   print("Sleeping 2", i)

And when i spawn them both at the same time i get this:

Sleeping 1, 1
Sleeping 2, 1
Sleeping 1, 2
Sleeping 2, 3
Sleeping 1, 4
Sleeping 2, 5
Sleeping 1, 6
Sleeping 2, 7
Sleeping 1, 8
Sleeping 2, 9
Sleeping 1, 10

So i guess it that both coroutines share the environment where 'i' is stored, or am i doing something wrong when i'm newing the coroutines?

// David Morris-Oliveros
// Camera & Lua Coder
// Team Bondi

Team Bondi Pty Ltd
Level 2, 608 Harris Street
Ultimo, NSW 2007
Tel: +61 (0)2 8218 1500
Fax: +61 (0)2 8218 1507
This email may contain confidential information.  If you are not
the intended recipient, you may not copy or deliver this message to
anyone. In such case, you should destroy this message and kindly
notify the sender by reply email. Opinions, conclusions and other
information in this message that do not relate to the official business
of our firm shall be understood as neither given nor endorsed by it.