fnpy / fn.py

Missing features of fp in Python -- active fork of kachayev/fn.py
Other
149 stars 14 forks source link

Add recur.stackless(). #25

Closed jahs closed 7 years ago

jahs commented 7 years ago

Hi, this is a generalisation of recur.tco(). It can deal with recursive calls in a non-tail position, by implementing the recursive function as a generator and using generator.send() with a return stack in the trampoline. Thanks.

jacobbridges commented 7 years ago

Hey @jahs, thanks for the the feature! This should make tail call recursion much more optimized.

Your code is failing to run against pypy3 (ref), though from the output it looks like tox might be having an issue setting up pypy3. I will look into it.

jahs commented 7 years ago

I use it mainly for functions that are naturally (non-tail) recursive - then a "naive" implementation is actually usable, avoiding the brain ache and lack of clarity of re-writing to continuation passing style. Yes it looked like a tox problem - thanks!

medecau commented 7 years ago

@jacobbridges pypy3 is no longer a problem since #27 See: #28

jahs commented 7 years ago

Hi I just fixed a edge-case bug. Is this good to go in? Thanks.

jahs commented 7 years ago

Hi is this going in? I've got another project which I'd like to make this a dependency of. Thanks.

jacobbridges commented 7 years ago

Hi @jahs, I'm so sorry for the delay. We have recently moved so I've had little time to look at this.

I'll merge in the code, do some testing, then push out an updated version to pypi right away.

jahs commented 7 years ago

Very kind, thanks.

jacobbridges commented 7 years ago

This has been merged and deployed to pypi.