[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: an Interval factory
- From: spir ☣ <denis.spir@...>
- Date: Wed, 26 May 2010 13:41:14 +0200
On Wed, 26 May 2010 12:41:51 +0200
Wim Couwenberg <wim.couwenberg@gmail.com> wrote:
> > It's a useful pattern, but rather slow if just implemented as an
> > iterator.
>
> "slow" triggers me.. :-) I guess that either it doesn't matter, in
> which case ipairs could stay, or it *does* matter, in which case I
> don't get why pairs is not discussed as well.
I meant this as a replacement for numeric-for -- which imo is not needed since we have the generic for. All we need is a standard & efficient way to represent a numeric interval and let it deliver 'items'.
The example implementation as a plain Lua iterator is just this, an example. As a builtin feature it should run at C speed and certainly not translate into C the scheme of a Lua iterator. As I said before, I guess the internal representation could be similar to, if not directly reuse, the one used for a numeric-for. There is no reason for it to run significantly more slowly.
The result is just language simplification: use a general scheme (generic-for traversal loop) everywhere it fits, instead of special-casing where it is not necessary.
(Now, this is just a pov, I won't fight for it ;-)
Denis
________________________________
vit esse estrany ☣
spir.wikidot.com