instantiating generators

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Mar 15 13:23:23 PDT 2013


for what is worth it, agreed with Tab Atkins here ... `new` does not
improve much semantically speaking, it's actually just confusing, IMHO


On Fri, Mar 15, 2013 at 1:18 PM, Tab Atkins Jr. <jackalmage at gmail.com>wrote:

> On Fri, Mar 15, 2013 at 11:51 AM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
> > On Mar 15, 2013, at 11:22 AM, Axel Rauschmayer wrote:
> >> I would prefer having to use `new` (but don’t have strong feelings about
> >> it): generators are more like constructors than like functions. When I
> first
> >> started experimenting with them in Firefox, it took me a while to figure
> >> that out (even though it is obvious in hindsight). With `new`, I’d
> probably
> >> have figured it out quicker.
> >
> > My experience was similar.
>
> Mine's the opposite - my experience with generators in Python built up
> a strong and very natural-feeling intuition that a generator was just
> a function that returned a "magic list".  Trying to push that into a
> constructor notion would feel awkward.
>
> Actually using it would be even more awkward than thinking about it, I
> believe.  For example, I use the enumerate() generator *all the time*
> in Python.  Having to always write:
>
>     for(x of new enumerate(seq)) {...}
>
> would feel really weird, even if you changed the conjugation of the
> function to "enumeration()".
>
> ~TJ
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130315/c1a76c6b/attachment.html>


More information about the es-discuss mailing list