Fork me on GitHub
#lsp
<
2022-09-15
>
sheluchin11:09:58

Any thoughts on refactorings for cycling through different ways to perform iteration? Something like: • doseq <-> run!`mapv` <-> into • on the riskier side, collection transformations e.g. ->> <-> transduce • etc.

borkdude11:09:54

Why would you change mapv into into? mapv already calls into

sheluchin11:09:23

@U04V15CAJ Ah, I didn't know that! Do you think there are any valid cases for a code action like this?

borkdude11:09:53

I like the doseq -> run! one, since run! yields smaller code

sheluchin11:09:25

The ->> -> transduce one seems like a nice efficiency upgrade. The stack is essentially the same in both, but the transducer doesn't retain everything in memory.

borkdude11:09:02

->> with seqs also doesn't retain everything in memory?

borkdude11:09:16

if you release the head of a seq, it can be garbage collected

borkdude11:09:39

but yeah, if this can be done accurately, it would be nice

sheluchin11:09:44

My understanding is that it still creates intermediate sequences between each step and puts a strain on the GC when using a large collection, while the transduce version does not. In any case, the example list is short and not complete. There are probably a few other such transforms that could be considered.

borkdude11:09:06

This is true, but it doesn't hold everything in memory

sheluchin12:09:07

I see. So still an efficiency gain but not for all the reasons I thought. Thanks for the correction.

jacob.maine16:09:58

FWIW Alex Miller https://groups.google.com/g/clojure/c/9I6MtgOTD0w/m/Cif1Z8OB8HwJ tool developers to support a ->> <-> eduction refactoring 7 years ago. eduction is still pretty obscure, from what I’ve seen, but perhaps it should be another candidate

sheluchin16:09:33

Thanks, @U07M2C8TT. Okay, it sounds like there is at least a little interest in this idea. I'll create an issue for it just to put it on the radar.