Getting started with Lisp's OCaml, I'm very confused when functions return and when not. I miss my magic quote! Fortunately, most of the time, OCaml seems to automatically know when I want the function to be evaluated, and when not. However, I often try to assign the return value of a function in a let expression, as shown below.
let start = Sys.time in (* * do something here *) ; let ending = Sys.time in Printf.printf "did something in %f seconds\n" (ending -. start)
but then ocamlc complains
Error: This Expression has type unit -> float but an expression was expected of type float
Tell us that the start and end are tied to Sys.time , and not to the return value of Sys.time .
Is this behavior I'm trying to get non OCamly? I want to do something different? Did I just miss something completely obvious?
variable-assignment functional-programming ocaml
Eli
source share