为什么在F#Interactive中打印5000个数字会导致StackOverflowException?
在Windows7上的F#3.1上测试为什么在F#Interactive中打印5000个数字会导致StackOverflowException?,f#,f#-interactive,F#,F# Interactive,在Windows7上的F#3.1上测试 fsi.PrintLength我认为这是中的一个bug,它负责将漂亮的打印输出到F#Interactive 有一些非尾部递归函数使用PrintLength,例如本例中的boundedInfoldl。实际上,的实现不是尾部递归的: let boundedUnfoldL (itemL : 'a -> layout) (project : 'z -> ('a * 'z) op
fsi.PrintLength我认为这是中的一个bug,它负责将漂亮的打印输出到F#Interactive 有一些非尾部递归函数使用
PrintLength
,例如本例中的boundedInfoldl
。实际上,的实现不是尾部递归的:
let boundedUnfoldL
(itemL : 'a -> layout)
(project : 'z -> ('a * 'z) option)
(stopShort : 'z -> bool)
(z : 'z)
maxLength =
let rec consume n z =
if stopShort z then [wordL "..."] else
match project z with
| None -> [] // exhaused input
| Some (x,z) -> if n<=0 then [wordL "..."] // hit print_length limit
else itemL x :: consume (n-1) z // cons recursive...
consume maxLength z
让boundednfoll
(项目L:'a->布局)
(项目:'z->('a*'z)选项)
(stopShort:'z->bool)
(z:'z)
最大长度=
让rec消耗nz=
如果停止短z,则[wordL”…]否则
将项目z与
|无->[]//未使用的输入
|一些(x,z)->如果n 5000成功
您可以将此作为错误报告给。听起来F#Interactive可能会受益于他们在F#4.0中修复了它?