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

Tail recursion elimination #17

Open
rrthomas opened this issue Dec 9, 2023 · 3 comments
Open

Tail recursion elimination #17

rrthomas opened this issue Dec 9, 2023 · 3 comments

Comments

@rrthomas
Copy link
Collaborator

rrthomas commented Dec 9, 2023

Add an exception ArkTailCall that replaces ArkCall for tail calls. Use it whenever we're in tail position, which we'll track with another argument to toAST, which is true when the parent is in tail position. Then if we're in tail position and our parent is and we're calling the current function (another new argument to toAST) then use ArkTailCall instead of ArkCall.

@apt1002
Copy link
Collaborator

apt1002 commented Dec 13, 2023

Why only if we're calling the current function?

@rrthomas
Copy link
Collaborator Author

The situation has changed. For the reference interpreter it may be a good idea to eliminate tail calls, but it's less urgent. The worst we can do is exhaust memory (that stack will be on the heap).

ES2015 has tail calls in strict mode; we should ensure we're using this where possible.

@rrthomas
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants