-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
dotnet-fsharp/svchelp wantedGood for community contributors to help [up-for-grabs]Good for community contributors to help [up-for-grabs]resolved-by-customer
Description
Type of issue
Typo
Description
This is given as the Tail Call Optimized version of fib but it doesn't actually use the TailCallAttribute. Furthermore, it is unobvious to me if [<TailCall>] should be placed on fib or on the inner recursive loop binding.
I don't think the attribute can even be applied on loop binding, but fib isn't actually recursive. If putting the attribute on fib is correct, that suggests that any function inside fib would have this TailCall constraint which seems like an inappropriate restriction.
let fib n =
let rec loop acc1 acc2 n =
match n with
| 0 -> acc1
| 1 -> acc2
| _ ->
loop acc2 (acc1 + acc2) (n - 1)
loop 0 1 n
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
Content source URL
Document Version Independent Id
4aececf7-7876-3bc1-f722-1004b25fe05d
Platform Id
e195630b-53b2-2298-0270-c4ba6e3a3bd9
Article author
Metadata
- ID: 029d87c5-6502-8151-c903-dec53a570b0a
- PlatformId: e195630b-53b2-2298-0270-c4ba6e3a3bd9
- Service: dotnet-fsharp
Metadata
Metadata
Assignees
Labels
dotnet-fsharp/svchelp wantedGood for community contributors to help [up-for-grabs]Good for community contributors to help [up-for-grabs]resolved-by-customer