- From: Cameron McCormack <cam@mcc.id.au>
- Date: Thu, 28 Jun 2012 12:30:37 +1000
- To: Jason Orendorff <jason.orendorff@gmail.com>
- CC: public-script-coord <public-script-coord@w3.org>
I've added iterators to the spec: * Interfaces that have an indexed property getter automatically get an iterator() method on their prototype that returns an array index iterator (just like Array.prototype.iterator would). * Interfaces can be declared to have a custom iterator (which would override the automatic indexed property getter one if it would otherwise have one), like this: interface NodeList { Node iterator; }; You then define in prose what the "iterator behavior" is for a NodeList, which given some state defines what is the next value to return. There exists an "iterator prototype object" for each interface that declares an iterator in this way -- so here there would be a NodeListIterator prototype object, which is the [[Prototype]] for objects returned from NodeList.prototype.iterator. * You can declare that the iterator object implements a particular interface: interface NodeList { Node iterator = NodeIterator; }; in which case the iterator object interface must be declared like so: interface NodeIterator { Node iterator object; }; When this form is used, you define in prose how to "create an iterator object" for a NodeList (i.e. how you would create a NodeIterator object that knows it is iterating over a particular NodeList) and also what the "iterator object behavior" is for NodeIterator, which given the NodeIterator object as the state, what the next value to return is. There are examples in the spec of these prose definitions that would be required. http://dev.w3.org/2006/webapi/WebIDL/Overview.html#idl-iterators http://dev.w3.org/2006/webapi/WebIDL/Overview.html#es-iterators http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.557;r2=1.554;f=h
Received on Thursday, 28 June 2012 02:31:11 UTC