New iterate and cycle impls have delayed computations but don't implement IPending

Description

When moving from LazySeqs to the new types we lost this but I don't think we should. Tools like Cursive use this for deciding when and how much to realize from a lazy sequence.

Approach:

  • iterate - The head of an iterate will always have the seed value and return 1 realized value. Subsequent elements will start unrealized and then become realized when the iterate function has been invoked to produce the value.

  • cycle - Returns unrealized if _current has been forced (initially null for all nodes after the first node).

(Note that range and repeat effectively always have their first element realized so I have chosen not to implement IPending - there is no delayed computation pending.)

Patch: clj-1726-2.patch

Environment

None

Attachments

2

Activity

Show:

Nicola Mometto June 5, 2015 at 3:53 PM

Patch committed and the ticket marked as resolved but not closed. I'm closing it.

Fogus May 8, 2015 at 3:44 PM

There are three things that I like about this patch:

1) The implementations of the isRealize method provide meaning to the somewhat opaque encoding inherent in _current and (less opaque) UNREALIZED_SEED.

2) The use of realized? is generally useful outside of IDE contexts.

3) It's small and easy to grasp.

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created May 6, 2015 at 10:17 PM
Updated June 5, 2015 at 3:53 PM
Resolved June 5, 2015 at 3:53 PM