[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 16:06:34 -0000
Argg! How can you put metatables and the colon operator in and then complain
when people want to implement OO? I am not asking you to *enforce* OO for
iterators, just to *support*
it in the same way you support arithmetic and logical operations on tables
used to implement Classes. Whether you want to express it in OO or in
functional language (or ideally support both) having "generic for" implies
the iteration property/ operation/ function /action at a purely conceptual
level.
What is the conceptual difference between "iteration" and, say, "arithmetic"
which means that one deserves OO support (via metatables) and the other does
not?
Once the concept is admitted it ought to have the same flexibility of
expression in different paradigms as other similar concepts.
** In passing, please note that this *does not* violate the (honoured
mostly) principle that metatables should provide fallbacks not overrides.
Currently if you execute:
x = {}
for k in x do end
You get an error: "attempt to call a table value". So the proposed __iter
would just be a fallback for this error in this context.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Roberto
Ierusalimschy
Sent: 16 December 2009 15:23
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.
I was about to write this, but you were faster. Thanks,
-- Roberto