Re: [Caml-list] Optional arguments "between" non-optional ones

2010-09-23 Thread Jacques Garrigue
On 2010/09/24, at 0:05, Adrien wrote: > On 23/09/2010, bluestorm wrote: >> (sorry for any double-posting) >> >> The problem is that in your declaration of h, the inferred type for f >> is of the form (unit -> unit -> ...), and you use it with the >> different type (unit -> ?a:'a -> unit -> ...).

Re: [Caml-list] Optional arguments "between" non-optional ones

2010-09-23 Thread Adrien
On 23/09/2010, bluestorm wrote: > (sorry for any double-posting) > > The problem is that in your declaration of h, the inferred type for f > is of the form (unit -> unit -> ...), and you use it with the > different type (unit -> ?a:'a -> unit -> ...). > > Changing ?a to be the first parameter of f

Re: [Caml-list] Optional arguments "between" non-optional ones

2010-09-23 Thread bluestorm
(sorry for any double-posting) The problem is that in your declaration of h, the inferred type for f is of the form (unit -> unit -> ...), and you use it with the different type (unit -> ?a:'a -> unit -> ...). Changing ?a to be the first parameter of f change f's type to (?a:'a -> unit -> unit ->

[Caml-list] Optional arguments "between" non-optional ones

2010-09-23 Thread Adrien
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 ->

Re: [Caml-list] Optional arguments

2008-11-10 Thread malc
On Sun, 9 Nov 2008, David Teller wrote: What were you expecting? Your definition of [a] always passes argument [i] to [b], so the default value is never used. Yes indeed, i probably should quit writing code this late, sorry for the noise. -- mailto:[EMAIL PROTECTED]

Re: [Caml-list] Optional arguments

2008-11-09 Thread David Teller
What were you expecting? Your definition of [a] always passes argument [i] to [b], so the default value is never used. Cheers, David On Sun, 2008-11-09 at 22:17 +0300, malc wrote: > Objective Caml version 3.10.0 > > # let a i = let b ?(i=i mod 3) () = i in b ~i ();; > val a : int -> int = > #

[Caml-list] Optional arguments

2008-11-09 Thread malc
Objective Caml version 3.10.0 # let a i = let b ?(i=i mod 3) () = i in b ~i ();; val a : int -> int = # for i = 0 to 5 do print_int (a i); done;; 012345- : unit = () Is this something to be expected? Or perhaps something which calls for an upgrade? -- mailto:[EMAIL PROTECTED]