On dropping @names

Brendan Eich brendan at mozilla.org
Mon Dec 3 18:31:10 PST 2012


Axel Rauschmayer wrote:
>>> let iterable = { *[iterator]() { yield 5; } };
>>>
>>> Presented without comment...
>>
>> I'm sorry, but I reject this kind of argument. That code is simply 
>> more concise than:
>>
>>    let iterable = { [iterator]: function*() { yield 5 } };
>
> Given that the concise notation means that ': function' is omitted, 
> wouldn’t it be better to write:
>
>>> let iterable = { [iterator]*() { yield 5; } };

Maybe, but I think the star should come first. The problem is that 
function* iterator() { yield 5; } is the named generator function form. 
* after function and before name. * before name preserved in the 
property definition case means *[iterator]() { yield 5; }.

/be


More information about the es-discuss mailing list