Skip to content

Instantly share code, notes, and snippets.

@larsw
Last active August 26, 2015 08:10
Show Gist options
  • Save larsw/235e4a35c1470e575eee to your computer and use it in GitHub Desktop.
Save larsw/235e4a35c1470e575eee to your computer and use it in GitHub Desktop.
Unexpected sequence of output on Linux/F# 3.1/Mono 3.12.0 (expected "foo" to be output after the numerical sequence)
let seqGen a b =
seq {
yield! seq { a .. b }
raise (System.UnauthorizedAccessException("foo"))
}
try
seqGen 1 10
|> Seq.iter (fun x -> printf "%A " x)
with
| :? System.UnauthorizedAccessException as uae -> eprintfn "%A" uae.Message; exit -1
exit 0
# F# 3.1 / mono 3.12.0 / Ubuntu Linux 15.04
"foo"
1 2 3 4 5 6 7 8 9 10
[Finished in 3.045s]
# F# 3.1 / .NET 4.5.x / Windows 7
1 2 3 4 5 6 7 8 9 10
"foo"
@larsw
Copy link
Author

larsw commented Aug 26, 2015

With s/eprintfn/printfn/ on line 11, the output is ordered as expected.

Seems like processing of stderr has higher precedence than stdout in the terminal subsystem in Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment