4 ms·
Check this Ocaml talk by Yaron Minsky from Jane Street Capital: http://news.ycombinator.com/item?id=1533275 http://news.ycombinator.com/item?id=1533275 He said
by nivertech 16y ago
Check this Ocaml talk by Yaron Minsky from Jane Street Capital:
http://news.ycombinator.com/item?id=1533275 http://news.ycombinator.com/item?id=1533275
He said, that unlike Ocaml, in F# you still can get Null-pointer exceptions, since it's based on .NET
- gtani 16y ago(Disclaimer: f# neophyte, reading Chris Smith's excellent Oreilly book). I think the Option type is used similarly in F# to the Option/Maybe's in scala and haskell: http://msdn.microsoft.com/en-us/library/dd233245.aspx http://msdn.microsoft.com/en-us/library/dd233245.aspx
- ppog 16y agoThat's partly correct. The danger comes not because F# is "based on" .NET but because it can call into other .NET libraries. F# code by itself, including the F# libraries, won't create null references except in two very specific cases (see http://msdn.microsoft.com/en-us/library/dd233197.aspx http://msdn.microsoft.com/en-us/library/dd233197.aspx). And F# types are non-nullable unless you ask for them to be nullable. But if you call into non-F# libraries, including .NET framework libraries, then they can return null references. And if your F# code tries to use a null reference obtained in this way OO-style (e.g. making an instance method call through the reference), then that will indeed cause a NullReferenceException. Obviously, it's easy to wrap 'dangerous' calls to return option values (F#'s equivalent of Haskell Maybe) instead of nulls -- it's a judgment call as to whether it's worth it for any given API.