The following fragment compiles without a warning but produces strange results:

let f ?(p1="p1") ~p2 p3 =
  Printf.printf "p1=%s, p2=%s, p3=%s\n" p1 p2 p3

let _ =
  f "p2" "p3"; (* 1 *)
  let f2 = f "p2" in
  f2 "p3" (* 2 *)

Outputs:

p1=p1, p2=p2, p3=p3 (1)
p1=p1, p2=p3, p3=p2 (2)

Why (1) and (2) are different? I assume f "p2" takes p3 instead of p2
but then the compiler should issue at least a warning...

- Dmitry Bely

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to