Skip to end of metadata
Go to start of metadata

With the addition of transducers, a new opportunity for optimization has opened up, specifically around data generation functions like cycle and repeat. There are however several obstacles to simply enabling IReduce on these functions: 

  • Backwards compatibility must be maintained, i.e. these functions should still return seqs
  • If existing functions use chunked sequences it may be unwise to downgrade the functions to 'normal' seqs as a side-effect of enabling IReduce
  • Most of these functions do not have an arity overload available that makes sense to return a reducible vs a seq

 

Considered Solutions: 

  • Forget about making these things implement IReduce
  • Implement a new function with a different name (and naming convention) that returns something that implements IReduce.
  • Create a reducable LazySeq. Something that looks/acts like LazySeq, but also has a IFn field that says "if you want to reduce, this is the reducing function", then repeat could look something like this:

     While this could work, it also involves an addition allocation (the reduce logic function) on every cell in a lazy seq, probably not optimal. 
     

  • Probably other options I haven't thought about.....
Labels: