lua-users home
lua-l archive

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


On Fri, Sep 11, 2009 at 10:19 AM, John Hind <john.hind@zen.co.uk> wrote:
> I am coming round to the attractions of the "method" proposal for multiple
> iterators - the one where you can write:
>
> for v in myobject:myiterator do print(v) end

So one doesn't have to say?

for v in myobject:myiterator() do print(v) end

This seems a wee bit odd, to make a core change so that we save two
characters and end up confusing people anyway.

Currently obj:method has no meaning without the parentheses.  There
has been a proposal from Mark Hamburg that it should mean a closure
that works like this:

function (...)
  return obj:method(...)
end

This would be a useful shortcut for functional styles where you would
be passing functions for 'bulk' operations on tables, although again
there are possibilities for confusion which may make this not
desirable.

steve d.