On Thu, Jul 25, 2013 at 8:44 AM, Claus Reinke <[email protected]> wrote:
> I do not understand why (1) iterators are specified using a self-updating
> API when a functional API would seem preferable, or why (2) generators are
> linked to functions, when block-level generators would seem to be sufficient
> and less complex. In some more detail:
>
> 1. Why do iterators have an imperative API?
>
>    As currently specified, an Iterator's next returns a {done,value} pair
>    (ItrResult), updating the Iterator in place. A functional alternative
> would have next return a {done,value,next} triple, leaving the original
> Iterator unmodified.
>    It seems a lot easier to implement the imperative API in terms of
>    the functional one than the other way round, if one needed both.    In
> practice, I do not see any advantage to forcing an imperative API.

The imperative API is more performant in general, as it doesn't
require the allocation of a new iterable object at every iteration.

(I also prefer the functional approach, but I understand the arguments
against it, and am fairly comfortable with languages that use
imperative iterators, like Python and PHP.)

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to