From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA10695 for caml-red; Thu, 21 Sep 2000 09:37:39 +0200 (MET DST) 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 WAA05337 for ; Wed, 20 Sep 2000 22:15:11 +0200 (MET DST) Received: from batman.labri.u-bordeaux.fr (batman.labri.u-bordeaux.fr [147.210.8.5]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e8KKFAv01745 for ; Wed, 20 Sep 2000 22:15:10 +0200 (MET DST) Received: from serveur2-1.labri.u-bordeaux.fr (root@serveur2-1 [147.210.8.176]) by batman.labri.u-bordeaux.fr (8.8.7/8.8.7) with ESMTP id WAA24892 for ; Wed, 20 Sep 2000 22:17:48 +0200 (MET DST) Received: (from vanicat@localhost) by serveur2-1.labri.u-bordeaux.fr (8.9.3/8.8.8/Debian/GNU) id WAA27289; Wed, 20 Sep 2000 22:15:09 +0200 X-Authentication-Warning: serveur2-1.labri.u-bordeaux.fr: vanicat set sender to vanicat@labri.u-bordeaux.fr using -f To: caml-list@inria.fr Subject: Re: problem with optional arguments References: <39C8938F.8DFC8039@dia.uniroma3.it> From: Remi VANICAT In-Reply-To: "Dr. Wolfgang Gehrke"'s message of "Wed, 20 Sep 2000 12:38:07 +0200" Date: 20 Sep 2000 22:15:08 +0200 Message-ID: User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: weis@pauillac.inria.fr "Dr. Wolfgang Gehrke" writes: > Hello, > > could someone advice me how to resolve the following problem: > > The following works fine: > > class test1 ~(a:int) () = > object > val a = abs a > method a = a > method strange x = new test1 ~a:x () > end > > let t1 = new test1 ~a:(-10) () > > But on the other hand with an optional argument it does not compile, > neither: > > class test2 ?(a:int) () = > object > val a = abs a > method a = a > method strange x = new test2 ~a:x () > end it's seem normal, which value have a if the optional argument is not given ? in fact, ?a avec type 'a option, you should give a default value. then there is another problem : class test2 ?(a=0) () = object val a = abs a method a = a method strange x = new test2 ~a: x () end don't work, but i don't see realy why (the message of error is : The expression "new test2" has type ?a:int -> unit -> test2 but is used with type 'a -> unit -> 'b ) but class test2 ?(a=0) () = object val a = abs a method a = a method strange x = new test2 ?a: (Some x) () end work, and let you see that the argument of an optional argument is realy of type something option -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat