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

[SR-7941] Add annotation that will support tail recursion optimization #50476

Open
swift-ci opened this issue Jun 9, 2018 · 1 comment
Open
Labels
compiler The Swift compiler in itself feature A feature request or implementation performance

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 9, 2018

Previous ID SR-7941
Radar None
Original Reporter GrzegorzLeszek (JIRA User)
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 88376782a09d0612c59d8805a91a37ad

Issue Description:

As a user of swift language, a don't feel comfortable with using recursive functions, because I cannot reason about when tail recursion optimization would be used.

To solve this problem an annotation could be used that would give a hint that I would like to use a recursive function. If the tail recursive optimization could not be guaranteed, a warning with the appropriate message could be displayed.

currently:
func fibonacci(n: Int) {
if (n < 2) {
return 1;
} else {
return fibonacci(n-2) + fibonacci(n-1)
}
}

with annotation:
@tail
func fibonacci(n: Int)

if the optimization could not be guaranteed, a warning could be displayed:

@tail < warning: could not guarantee
func fibonacci(n: Int)

@belkadan
Copy link
Contributor

belkadan commented Jun 9, 2018

I know there's been discussion of a feature like this before, so I suggest checking out the forums too.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation performance
Projects
None yet
Development

No branches or pull requests

3 participants