Re: Support for generators

On Nov 6, 2012, at 11:35 AM, David Bruant wrote:

> Hi,
> 
> The WebAPI team at Mozilla defined the DeviceStorageAPI [1] which contains the following:
> interface DeviceStorage {
>  /* ... */
> // See interface below for how to use this
> DeviceStorageCursor enumerate(optional DOMString directory)
> DeviceStorageCursor enumerateEditable(optional DOMString directory)
> };
> 
> interface DeviceStorageCursor : DOMRequest {
> void continue();
> };
> 
> It really feels like an ES6 generator [2]. Is it possible to add a new keyword that would allow people defining WebIDL interfaces to define generators so that we have consistent interfaces between ES code and web API code? For the ECMAScript binding, this keyword would obviously refer to an generator.

A generator is mostly just a way to implement an iterator, so it is probably the iterator interface that you would want to specific, expect for rare situations where you need the extra API surface area (send, close, throw) of a generator.

In most cases, it can probably be left to an implementation to decide whether nor not is uses a generator to implement the iterator contract.  

Allen

Received on Wednesday, 7 November 2012 01:36:33 UTC