Re: [Caml-list] default arguments in classes

2009-06-16 Thread Martin Jambon
Jacques Le Normand wrote: > Hello list, > I'm trying to define a method with a default argument, but I keep > getting an error. Here's the code: > > class foo = > object (self) > method bar ?(baz="moo") () = > (new foo)#bar ~baz () > end > > and the error: > > The expression "new fo

Re: [Caml-list] default arguments in classes

2009-06-16 Thread Paolo Donadeo
This should work: # class foo = object method bar = let helper a b ?(c = "") () = Printf.printf "a = %d; b = %b; c = %s\n" a b c in helper end;; class foo : object method bar : int -> bool -> ?c:string -> unit -> unit end Any undesired side effects? -- Paolo ~ ~ :

[Caml-list] default arguments in classes

2009-06-16 Thread Jacques Le Normand
Hello list, I'm trying to define a method with a default argument, but I keep getting an error. Here's the code: class foo = object (self) method bar ?(baz="moo") () = (new foo)#bar ~baz () end and the error: The expression "new foo" has type foo but is used with type < bar : baz: