Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReturnFromTailcall, YieldFromTailcall #1200

Closed
dsyme opened this issue Nov 7, 2022 · 2 comments
Closed

Add ReturnFromTailcall, YieldFromTailcall #1200

dsyme opened this issue Nov 7, 2022 · 2 comments

Comments

@dsyme
Copy link
Collaborator

dsyme commented Nov 7, 2022

Placeholder to track a suggestion from here fsprojects/FSharp.Control.TaskSeq#62 (comment)

Essentially it's too hard to implement builders for computations that respect tailcalls correctly. However, the analysis can easily be done in the compiler treatment of computation expressions. We should support this in the language.

@abelbraaksma
Copy link
Member

abelbraaksma commented Dec 18, 2022

You’re writing “it’s too hard”. I know we attempted an implementation by using ReturnFrom in TaskSeq with trampolining, however, that only worked where the first of the two returns was returning unit. Also, semantically, return(!) has no place in sequence builders with yield.

I’m wondering if “too hard” here means “there’s a way to code it”, or “it’s impossible without explicit language support”. Specifically directly through existing YieldFrom.

I mean, I don’t see a way to detect in code that yield! is recursive. The way this is solved in AsyncSeq is by using a continuation passing style throughout, which comes with detrimental performance as it is becomes necessary to build and allocate a new sequence for each bind (ie, let! there wraps the whole sequence in a new sequence with one additional member, requiring two extra interface allocations).

If there is a way currently, I’d be interested to know how :).

@dsyme
Copy link
Collaborator Author

dsyme commented Apr 13, 2023

This is the same as #1006

@dsyme dsyme closed this as completed Apr 13, 2023
@abelbraaksma abelbraaksma closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants