English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2010-09-23 (13:21)
From: Adrien <camaradetux@g...>
Subject: [Caml-list] Optional arguments "between" non-optional ones

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?



Adrien Nader