[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: '__iter', yet again!
- From: spir <denis.spir@...>
- Date: Wed, 16 Dec 2009 19:41:44 +0100
Jerome Vuarand <jerome.vuarand@gmail.com> dixit:
> 2009/12/16 John Hind <john.hind@zen.co.uk>:
> > I really cannot see why this solution is resisted – it is fully backward
> > compatible and syntactically uncomplicated. The context of the explist is
> > easily distinguishable being bracketed by the reserved words ‘in’ and ‘do’.
>
> The beauty of the language, is that it has very few concepts, used in
> many places. Rather than having a specific mechanism to iterate over
> objects, the for loop use the mechanisms of multiple return values and
> first class functions. The resistance comes from the fact that you
> want to make Lua more complicated, just to save an explicit method
> call. And that's assuming that the implicit __iter is better syntax
> than an explicit method, which is arguable (e.g. I would disagree with
> you). And concise and cryptic syntax overriding isn't even part of OO,
> it's just often bundled with it.
>
...but your argument applies to _all_ metamethods / overriding. What differs in the case of __call, __tostring or __add? For..in is a builtin operation on a table/object that, unlike others, lacks a matching metamethod.
Or do I misinterpret your meaning?
Denis
PS: Where are you from?
________________________________
la vita e estrany
http://spir.wikidot.com/