You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Additional Detail from JIRA
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)
The text was updated successfully, but these errors were encountered: