instantiating generators

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


but then the direction is a bit inconsistent since native constructors are
going to require `new


On Fri, Mar 15, 2013 at 1:36 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Tab Atkins Jr. 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()".
>>
>
> Don't worry, we are not going to require 'new'.
>
> /be
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130315/55ad7eb8/attachment.html>


More information about the es-discuss mailing list