[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: '__iter', yet again!
- From: "John Hind" <john.hind@...>
- Date: Wed, 16 Dec 2009 15:38:26 -0000
Now you are being really disingenuous!
What are metatables for if not to provide the infrastructure for OO? But when I use the word "object" here I am not implying OO, what I say applies just as well to base Lua table objects. However it is implemented in detail, "generic for" implies the existence of a conceptual property of "being able to be iterated".
Perhaps we should just deprecate "generic for" and simplify the language. In standard Lua we could have:
forpairs(table, function(k, v) ... end)
foripairs(table, function(i, v) ... end)
and in OO practice you would simply provide a method:
obj:foreach(function(child-obj) ... end)
All this would just use standard function/method infrastructure and there would be no special concept of iteration in the language.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Jerome Vuarand
Sent: 16 December 2009 15:12
To: Lua list
Subject: Re: '__iter', yet again!
That's not true, we don't have a concept of "objects which can be
iterated", we have a concept of iterator functions (next), and
iterator factories (pairs). This is completely different, and you are
wrongfully introducing object oriented concepts in a language that is
not OO.