【发布时间】:2013-08-27 19:54:49
【问题描述】:
我有这个代码:
let rec collect ( t : BCFile list ) ( acc : Set<BCFile> ) : Set<BCFile> =
match t with
| [] -> acc
| hr::tl -> collect ( tl ) ( Set.union acc ( FindSourceFilesForTarget ( hr ) ) )
let s = collect (Set.toList targets) Set.empty
看起来它应该是尾递归的,但它不是(查看 IL)。知道为什么它没有被编译为使用尾递归吗?
【问题讨论】:
-
你是在发布模式下编译吗?除非您处于发布模式,否则不会优化尾调用。
标签: .net f# tail-recursion tail cil