I have two functions:
let print_length = function | [] -> Printf.printf "The list is empty" | xs -> Printf.printf "The list has %d elements" (List.length xs) let print_length = function | [] -> Printf.printf "The list is empty" | (_ :: _) as xs -> Printf.printf "The list has %d elements" (List.length xs)
In practice, they behave the same, and in theory they should be identical if the cases are compared in a sequential order. But is this guaranteed in OCaml? What should I do if some newer version of the compiler starts optimizing compliance statements by reordering the order? In this case, only the second version will give the correct result. Should I worry about this?
source share