lua-users home
lua-l archive

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


Op 20 april 2012 18:27 heeft Daurnimator <quae@daurnimator.com> het
volgende geschreven:
>> On Fri, Apr 20, 2012 at 05:17:45PM +0200, Dirk Laurie wrote:
>>>
>>> Instead, I must say
>>>   for f in function(...) return object:method(...) end do

> It has been discussed before; see:
>
> http://lua-users.org/lists/lua-l/2010-01/msg00961.html
> http://lua-users.org/lists/lua-l/2009-09/msg00382.html
>

Thanks for the pointers.  LHF seems to have disqualified
the idea because it implies a hidden closure, which indeed
would be the case if I wanted to say newfunc=object:method.

I've just realized, though, that in the context of a for loop,
no closure is needed:

   for x in object:method do

means

    for x in object.method,object do

I can live with that, although the sugar would make the code
more immediately readable.  And I won't argue the case for
__iter again just yet …

Just hang on in there, Dirk, one of these days you'll finally
understand the generic for.