Status/Resolution/Reason: To Fix//Investigate
Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)
Created: 05/06/2013
Components: Language
Versions: 2016,11.0,10.0
Failure Type: Enhancement Request
Found In Build/Fixed In Build: Final /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Platforms All
Vote Count: 10
G'day:
I have to concede this is not a concept I have in the past thought "I rally wish CFML could do this", but havng read about it, I think it's pretty cool and would be a good addition to the language.
The description in the JS docs (https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Iterators_and_Generators) is straight forward, but basically there's two conceits:
Iterators
A standardised way of iterating over a collection. Native collection objects (eg: structs, arrays, queries, etc) would implement the Iterator interface (basically meaning it has a next() method), and components could likewise implement the interface. From there, there's a standard approach to iterating over collection objects, either manually using next(), or using a foreach() sort of loop.
Generators
This is pretty interesting. It allows for the definition of infinite sequences, by creating a function which has a yield statement in it. The function creates an iterator, and every time next)( is called on the iterator, the function is executed, returning the next element of the sequence.
Good examples are in this blog post: http://timtaubert.de/blog/2013/05/working-with-infinite-sequences-in-javascript/.
--
Adam
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3555025
External Customer Info:
External Company:
External Customer Name: Adam Cameron.
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: