Type: Feature Request
Status: Closed (View Workflow)
Resolution: Out of Date
Affects Version/s: 4.2.0.002
Fix Version/s: None
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.
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.
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.