lua-users home
lua-l archive

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


Egor does have a point though.  Since the for statement accepts a list
of values one would expect the usual rules about function calls and
adjustment of returned values to apply.  If you can say

a, b = f()

one would expect

for v = f() do ... end

to work to as well given the equivalent code used to define the for
statement in the manual.  Of course that would only feel natural given
the way the for statement is defined, things might be different if you
consider the way it is implemented.

On Thu, Sep 13, 2012 at 8:37 PM, Frank Meier-Dörnberg <frank@md-web.de> wrote:
> Am 13.09.2012 16:42, schrieb Egor Skriptunoff:
>
>> On 9/13/12, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>>
>>> The syntax of the numeric "for" is:
>>> for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end
>>> I.e. the comma is part of the syntax, and
>>>   exp ‘,’ exp [‘,’ exp] is not an expression list.
>>
>> Why numeric "for" syntax is not fully compliant with "Lua spirit"
>> (it implies possibility to feel free with multiple values returned
>> from a function anywhere instead of hard-coded list)?
>>
>>
>>
> May be an "iterator" what you are lokking for?
> E.g. see: http://www.lua.org/pil/7.1.html
>
> Cheers
> Frank
>