W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2012

Re: Support for generators

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Tue, 6 Nov 2012 17:36:16 -0800
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-Id: <2A94B565-B3F6-4515-AF41-B068E219CD94@wirfs-brock.com>
To: David Bruant <bruant.d@gmail.com>

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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:07 UTC