lua-users home
lua-l archive

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


I've implemented this as a power patch (http://lua.swiki.net/5).  I haven't
tested it much, but if anyone has a problem send me the details and I should
be able to fix it.  I didn't change existing opcode values, so presumably
it's binary compatible.

If anyone should happen to get addicted to this patch (as I suspect I will),
please consider adding your name to the "supporters" field on the wiki page
and let everyone know.

-John

(p.s. To access downloads on Swiki.net, browser cookies must be enabled.)


----- Original Message -----
From: "John Belmonte" <jvb@prairienet.org>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Thursday, April 26, 2001 6:15 PM
Subject: list iteration for statement


> I've been thinking it would be nice to have another form of the for
> loop on top of two we have now, for iterating lists:
>
>     for val in list do
>         print(val)
>     end
>
> The equivalent in the Lua as it is now:
>
>     for i = 1, getn(list) do
>         local val = list[i]
>         print(val)
>     end
>
> Such iteration (where the list is not modified) is very common.
>  My argument for adding this new form is that it's more terse,
>  less error prone (forgetting the local qualifier, etc), and faster
> if the list happens to be a global.
>
> Any thoughts?
>
> -John