instantiating generators

Brandon Benvie bbenvie at mozilla.com
Fri Mar 15 13:06:31 PDT 2013


Yeah but since the generator holds the initial |this| for its lifetime you can treat it kind of like a bound function.

On Mar 15, 2013, at 12:41 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

> Ah, methods are more tricky! Then you have `this` to contend with.
> 
> On Mar 15, 2013, at 20:02 , Brandon Benvie <bbenvie at mozilla.com> wrote:
> 
>> On 3/15/2013 11:51 AM, Allen Wirfs-Brock 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 was as well. Admittedly it's kind of odd to use something like `new obj.method` but it does more accurately describe what it was going on.
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> -- 
> Dr. Axel Rauschmayer
> axel at rauschma.de
> 
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130315/889c8b8f/attachment-0001.html>


More information about the es-discuss mailing list