Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: 4.2.0.002
    • Fix Version/s: None
    • Labels:
      None

      Description

      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

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                micstriit Michael Offner
                Reporter:
                adamcameroncf Adam Cameron
              • Votes:
                2 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: