caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Labelled parameter bug?
@ 2011-08-24 14:49 Dmitry Bely
  2011-08-24 15:01 ` Philippe Veber
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Bely @ 2011-08-24 14:49 UTC (permalink / raw)
  To: Caml List

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-26  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 14:49 [Caml-list] Labelled parameter bug? Dmitry Bely
2011-08-24 15:01 ` Philippe Veber
2011-08-26  9:20   ` Dmitry Bely
2011-08-26  9:58     ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).