TheAngryByrd / IcedTasks

F# Cold Tasks and Cancellable Tasks
https://www.jimmybyrd.me/IcedTasks/
MIT License
120 stars 5 forks source link

Tail Recursion #3

Open TheAngryByrd opened 2 years ago

TheAngryByrd commented 2 years ago

Is your feature request related to a problem? Please describe.

Tasks currently do not support tail call optimization. If we want to support more features like async does, then we should.

Describe the solution you'd like

I'm not smart enough to know what this looks like yet.

Describe alternatives you've considered

Don't do it. There's always an option not to.

Additional context Add any other context or screenshots about the feature request here.

TheAngryByrd commented 1 year ago

I looked into this over Christmas and it seems to be the case that is isn't simple because ReturnFrom doesn't know if we're coming from our own state machine builder or another Task/TaskLike and can't use hijack to call MoveNext on the statemachine.. I think we have to wait for F# compiler to implement https://github.com/fsharp/fslang-suggestions/issues/1200