lua-users home
lua-l archive

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


On Wed, Mar 02, 2011 at 12:59:09PM +0200, Axel Kittenberger wrote:
> > That's actually valid syntax already :-)
> >
> > function f(...)
> >    for i,v in ... do print(i,v) end
> >    end
> >
> > function g(x,y) if x~=y then return y+1, (y+1)^2 end end
> >
> > f(g,10,0)
> 
> Yes, but it isn't a varg iterator and its just dirty shortcuts
> 
> function f(iter, state, init)
>     for i,v in iter, state, init do print(i,v) end
>  end
> 
> function g(x,y) if x~=y then return y+1, (y+1)^2 end end
> 
> f(g,10,0)
> 
> would be clearer and better coded to what really is happening.

Agreed, but the point is that ... inside a generic for already
has a meaning, so one can't just make it mean something else.

Dirk