I just learned that OCAML have to have a .
postfix for doing float arithmetic. An example would be 3. +. 4.
which equals 7.
(float). H
In addition to Brian´s answer and link:
https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/prim-types.fs
I found some definitions in the code:
let inline (+) (x:int) (y:int) = (# "add" x y : int #)
and
let inline (+) (x: ^T) (y: ^U) : ^V =
AdditionDynamic<(^T),(^U),(^V)> x y
when ^T : int32 and ^U : int32 = (# "add" x y : int32 #)
when ^T : float and ^U : float = (# "add" x y : float #)
when ^T : float32 and ^U : float32 = (# "add" x y : float32 #)
...
And the AdditionDynamic
is defined here (loads of static stuff and CIL):
https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/prim-types.fs#L2374
Fun stuff:
(# "add" 1 2 : int32 #)
works, and gives 3 as output (with a warning saying you shouldn't do this.)