Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Optional arguments "between" non-optional ones
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Adrien <camaradetux@g...>
Subject: [Caml-list] Optional arguments "between" non-optional ones
Hi,

I was refactoring code today and hit a typing error that I couldn't
explain. I eventually tracked it down to the following:

  let f () ?a () =
    print_endline "bouh!"

  let h f =
    f () ()

  let () = h f;;  (* error is for "f" here *)

  Error: This expression has type unit -> ?a:'a -> unit -> unit
         but an expression was expected of type unit -> unit -> 'b


If I remove the first unit argument of f, then it works as expected.
There also seems to be variations around that.

Is there any explanation for that difference? And any chance of it
getting improved?

Thanks.


-- 

Adrien Nader