-
Notifications
You must be signed in to change notification settings - Fork 6k
[<TailCall>] not used in suggested version example #46257
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
Comments
tagging @T-Gro for his thoughts. |
In the content right below it, it is explained what
We will for sure be happy for any suggestion on how to make that more clear if needed. Regarding the inner function - indeed, attributes cannot be placed on inner function as of now (since those functions can get inlined and for a class of attributes, this would lead to unmet expectations - imagine putting ASP.NET related attributes but then at runtime it would inlined and removed...) |
Since this is the documentation about the TailCallAttribute, I think it's fair to expect to see an example where it is used properly in a passing scenario, no? Perhaps this can work as a simple, low-value example:
But then the original example would be more valuable to discuss. This is incorrect, but what is the suggested fix?
Must we do this?
|
Yes, it must be lifted to a top level function in order for attributes to be allowed. |
Uh oh!
There was an error while loading. Please reload this page.
Type of issue
Typo
Description
This is given as the Tail Call Optimized version of
fib
but it doesn't actually use theTailCallAttribute
. Furthermore, it is unobvious to me if[<TailCall>]
should be placed onfib
or on the inner recursiveloop
binding.I don't think the attribute can even be applied on
loop
binding, butfib
isn't actually recursive. If putting the attribute onfib
is correct, that suggests that any function insidefib
would have this TailCall constraint which seems like an inappropriate restriction.Can you please clarify in this example where to use
[<TailCall>]
? And discuss any interesting side-topics about that placement regarding propagation of the constraint?Page URL
https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/recursive-functions-the-rec-keyword
Content source URL
https://github.com/dotnet/docs/blob/main/docs/fsharp/language-reference/functions/recursive-functions-the-rec-keyword.md
Document Version Independent Id
4aececf7-7876-3bc1-f722-1004b25fe05d
Platform Id
e195630b-53b2-2298-0270-c4ba6e3a3bd9
Article author
@KathleenDollard
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: