Uploaded image for project: 'Commons Functor (Dormant)'
  1. Commons Functor (Dormant)
  2. FUNCTOR-14

Enhancements on the Generator API

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      Apparently, the Generator API in [functor] was created based on Python generators. However, there is room for enhancements in the current implementation.

      The Generator interface contains methods to stop its execution. However not all generators are necessarily 'stoppable'. Maybe we could move this behavior to a separate interface.

      The parameters passed to a generator (from, to, step) are the same that, in Python, can be used to create a Range. Ranges are used in many examples of Generators in Python. We could include Ranges in [functor] and utilize them in Generators. It would be good if we could include/exclude the Range boundary values, i.e. we could create a Range 0..2, and define 0 or 2, as being either inclusive or exclusive.

      Among the current generators, there is one for Integer's, and another one for Long's. We could create generators for other types too (e.g.: Char, Date, Double, Float, ...).

      Another feature usually related to Generators in Python is the yield statement. There are some API's in Java that provide a yield implementation. This is not entirely necessary, but could be convenient to include it to [functor] too, combined with Generators. Maybe in [functor] we could create a YieldProcedure. This way, the Generator would yield its values to this procedure. Just food for thought.

      This issue is quite vague, so feel free to add comments, or criticize. This way we can achieve a common consensus on a new and awesome Generator API for [functor]. No hard feelings

      Cheers

      Attachments

        Activity

          People

            kinow Bruno P. Kinoshita
            kinow Bruno P. Kinoshita
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: