Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Optional and mandatory labels with the same name in the same function ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-15 (14:49)
From: Jacques GARRIGUE <garrigue@k...>
Subject: Re: [Caml-list] Optional and mandatory labels with the same name in the same function ?
From: Richard Jones <>

> It's a bit more subtle than that.  OCaml 3.07 always picks the last
> argument, and ignores the others.  Thus:
> # let f x x = x;;
> val f : 'a -> 'b -> 'b = <fun>
> # let f x x x x = x;;
> val f : 'a -> 'b -> 'c -> 'd -> 'd = <fun>
> But a future version might pick the first argument, or one in the
> middle, or one at random.  I can't find any guarantee in the manual
> that the behaviour won't change, so this might cause a bug.

Well, it's not directly related to the question I was answering, but I
can reassure you. This behaviour is well defined, because
  let f x x = x
is no more than a shorthand for
  let f = fun x -> fun x -> x
which is quite natural for anybody versed in lambda-calculus.
I cannot cite you whre the manual specifies that, but this not a case
of undefined behaviour.

More generally, ocaml may leave some runtime behaviour unspecified,
but the static behaviour (type-checking) is expected to be fully

Jacques Garrigue

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: