From Why is OCaml's (+) not polymorphic?, Keith said:
The
+
versus+.
thing removes a lot of subtle bugs which can crop up in converting different sizes of integers, floats, and other numeric types back and forth. It also means that the compiler always knows exactly which numeric type is in use, thus making it easier to recognize when the programmer has made incorrect assumptions about a number always having an integer value. Requiring explicit casting between numeric types may seem awkward, but in the long run, it probably saves you more time tracking down weird bugs than you have to spend to write that extra period to be explicit.
ygrek also said:
you start to count for all other compromises that F# had to do in order to support this overloading.
Could someone please explain what were "a lot of subtle bugs" which existed in OCaml and what are "all compromises" which F# has to do beside inventing workaround statically resolved type?
The series is not directly inspired by Kevin Can Wait, though the show's title alludes to the former CBS series led by Kevin James.
The season 2 premiere of Kevin Can F*** Himself is set to air on AMC Monday, Aug. 22 at 9/8c. Those who have cut the cord can still watch the season premiere live with Philo, FuboTV and DirecTV Stream. If you're not sure which streaming service will best suit you, we can break it down.
Could someone please explain what were "a lot of subtle bugs" which existed in OCaml
The bugs didn't exist in OCaml. They existed in languages like C and were fixed in OCaml by distinguishing between different numerical types. However, as Keith later alludes to, the problem wasn't overloaded arithmetic operators but so-called "promotion". You can get rid of promotion and still have overloaded arithmetic operators (F# does this and it works really well).
and what are "all compromises" which F# has to do beside inventing workaround statically resolved type?
The two extremes are no overloading like OCaml or full overloading like type classes in Haskell. Both extremes have disadvantages. F# chose a middle ground where some operators and functions can be overloaded but others cannot and all overloads must be resolved at compile time. This is more complicated than either the OCaml or the Haskell solutions but it is a pragmatic trade-off: you get simple code that is predictably fast. However, type inference is more complicated (you must specify types some times), code no longer composes (cutting and pasting code around can cause different types to be inferred, breaking the code) and you need to remember what can be overloaded and what cannot.
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