From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA11791; Thu, 22 Mar 2001 09:20:43 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA11421 for caml-list@pauillac.inria.fr; Thu, 22 Mar 2001 09:20:43 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA11218 for ; Tue, 20 Mar 2001 23:15:21 +0100 (MET) Received: from moutvdom01.kundenserver.de (moutvdom01.kundenserver.de [195.20.224.200]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f2KMFKX16912 for ; Tue, 20 Mar 2001 23:15:20 +0100 (MET) Received: from [195.20.224.208] (helo=mrvdom01.schlund.de) by moutvdom01.kundenserver.de with esmtp (Exim 2.12 #2) id 14fUPP-0007RJ-00; Tue, 20 Mar 2001 23:15:19 +0100 Received: from drms-3e35780c.pool.mediaways.net ([62.53.120.12] helo=ice.gerd-stolpmann.de) by mrvdom01.schlund.de with esmtp (Exim 2.12 #2) id 14fUP9-0006dK-00; Tue, 20 Mar 2001 23:15:03 +0100 Received: from localhost (localhost [[UNIX: localhost]]) by ice.gerd-stolpmann.de (8.9.3/8.9.3) id XAA10306; Tue, 20 Mar 2001 23:14:48 +0100 From: Gerd Stolpmann Reply-To: gerd@gerd-stolpmann.de Organization: privat To: wester@ilt.fhg.de, caml-list@inria.fr Subject: Re: [Caml-list] classes and labels Date: Tue, 20 Mar 2001 23:11:48 +0100 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain References: <200103201502.QAA27766@ilt.fhg.de> In-Reply-To: <200103201502.QAA27766@ilt.fhg.de> MIME-Version: 1.0 Message-Id: <01032023143802.05414@ice> Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 20 Mar 2001, wester@ilt.fhg.de wrote: >Hi, > >I have the class definition: > ># class myclass ?(n=0) () = > object > val nn = n; > method get_nn = nn > method clone (na: int) = let (mc: myclass) = new myclass ~n:na () in mc; >end;; > >that produces the following error message in the toplevel: > > Characters 5-153: >The expression "new myclass" has type ?n:int -> unit -> myclass >but is used with type int -> unit -> myclass > >Can sombody tell what is wrong with my class definition? Nothing. It is a restriction of O'Caml 3.00. Your class definition works fine in 3.01. If you cannot upgrade, this is the workaround: # class myclass ?(n=0) () = object val nn = n; method get_nn = nn method clone (na: int) = let (mc: myclass) = new myclass ?n:(Some na) () in mc; end;; Gerd -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 100 64293 Darmstadt EMail: gerd@gerd-stolpmann.de Germany ---------------------------------------------------------------------------- ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr