fosskers / cl-transducers

Transducers: Ergonomic, efficient data processing
https://fosskers.github.io/cl-transducers/
Mozilla Public License 2.0
107 stars 4 forks source link

Adding first-class thunks? #7

Open simendsjo opened 7 months ago

simendsjo commented 7 months ago

I was creating my own enumeration library when I decided to look closer at cl-transducers. I'm using thunks for expensive computations. A few questions:

1) Would you like this added to cl-transducers8 Adding lazy to construct them, ensure-forced for evaluation etc.

2) Should knowledge about them be added to transducers that needs to look at the values? Changing (funcall pred input) to (funcall pred (ensure-forced input)) for the transducers that needs to evaluate the input. Without this, users themselves have to make sure to add a step to force evaluation before each transducer than needs to evaluate the input -- which seems quite leaky.

While it's very little code needed, it's more of an architectural question. I found for my own enumeration library that having lazy supported by take-while and similar functions made the calling code more robust. But it also means people writing transducers needs to know that they have to ensure thunks has been evaluated.

fosskers commented 7 months ago

I wanted to respond to this properly but did not manage to get to it this weekend (I was also out of town but for another reason). My trip starts tomorrow morning, so unfortunately I can't dedicate the time until I get back. Please forgive the delay.