Tested on F# 3.1 on windows 7
fsi.PrintLength <- 5000;;
[1..5000];;
Process is terminated due to StackOverflowException. Session termination detected. Press Enter to restart.
on Mono (F# 4.0), there doesn't seem to be such a limitation.
I think this is a bug in the formatting module that takes care of pretty printing to F# Interactive.
There are some non-tail recursive functions that uses PrintLength
e.g. boundedUnfoldL
in this line. Implementation of boundedUnfoldL
is indeed not tail-recursive:
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
I don't know why it doesn't blow up on Mono. It would be surprising if F# Interactive on Mono can handle length > 5000 successfully.
You can report this as a bug to https://visualfsharp.codeplex.com/workitem/list/basic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With