From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 5713EBBAF for ; Wed, 17 Jun 2009 00:39:57 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvYBAGu7N0pCbwQZlGdsb2JhbACYUgEBAQEJCwgJEwS6YoQLBQ X-IronPort-AV: E=Sophos;i="4.42,232,1243807200"; d="scan'208";a="31391973" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail1-smtp-roc.national.inria.fr with ESMTP; 17 Jun 2009 00:39:56 +0200 Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id 2DAD4361C67; Tue, 16 Jun 2009 18:39:56 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 16 Jun 2009 18:39:56 -0400 X-Sasl-enc: aA5HFgiQunZEr+AHi2ceQuL5dI8GSiFywMJ0DhtqxAOj 1245191995 Received: from [192.168.1.10] (ALyon-157-1-79-80.w90-37.abo.wanadoo.fr [90.37.70.80]) by mail.messagingengine.com (Postfix) with ESMTPSA id 429613CA48; Tue, 16 Jun 2009 18:39:54 -0400 (EDT) Message-ID: <4A381DF9.8060502@ens-lyon.org> Date: Wed, 17 Jun 2009 00:34:33 +0200 From: Martin Jambon User-Agent: Thunderbird 2.0.0.17 (X11/20081008) MIME-Version: 1.0 To: Jacques Le Normand Cc: caml-list caml-list Subject: Re: [Caml-list] default arguments in classes References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 foo:01 baz:01 foo:01 baz:01 annotations:01 wrote:01 incompatible:01 caml-list:01 jambon:01 jambon:01 define:02 expression:02 argument:02 string:02 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 foo" has type foo but is used with type > < bar : baz:string -> unit -> 'a; .. > > Types for method bar are incompatible > > how do I fix this? Adding type annotations often helps: class foo = object (self) method bar ?(baz="moo") () : unit = ((new foo) # bar : ?baz:_ -> _) ~baz () end Martin -- http://mjambon.com/