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

Support (case-lambda) tail recursion #46

Open
etaoins opened this issue Oct 8, 2014 · 0 comments
Open

Support (case-lambda) tail recursion #46

etaoins opened this issue Oct 8, 2014 · 0 comments

Comments

@etaoins
Copy link
Owner

etaoins commented Oct 8, 2014

R7RS requires (case-lambda) to be tail recursive. However, our new (case-lambda) generation has a few issues:

  • We always generate (case-lambda) with the same signature as TopProcedureType regardless of the types of the clause lambdas. This usually means we'll need to allocate a multiple values list at return which prevents tail recursion. It also uses the C calling convention which isn't required to support tail calls.
  • Clause lambdas don't have their recursive self values passed so they need to call through a cell which isn't supported
  • We never produce fixed arguments for (case-lambda)'s signature which means the a tail caller will always need to allocate a rest argument list. This doesn't prevent tail recursion but makes it potentially expensive
etaoins added a commit that referenced this issue Oct 15, 2014
Instead of giving all (case-lambda)s the same signature allow them to
have an individual tailored signature. This commit only gives them
the FastCC attribute and skips their self argument if none of the clause
lambdas capture.

This is a requirement for the the tail recursion work outlined in #46
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

1 participant