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 JAA10839 for caml-red; Thu, 21 Sep 2000 09:38:05 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA12106 for ; Thu, 21 Sep 2000 02:10:49 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e8L0AkX10178 for ; Thu, 21 Sep 2000 02:10:47 +0200 (MET DST) Received: from tet.kurims.kyoto-u.ac.jp (isdnppp2.kurims.kyoto-u.ac.jp [130.54.16.103]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id JAA04962; Thu, 21 Sep 2000 09:10:44 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by tet.kurims.kyoto-u.ac.jp (8.9.3/8.9.3) with ESMTP id JAA00566; Thu, 21 Sep 2000 09:08:25 +0900 (JST) (envelope-from garrigue@kurims.kyoto-u.ac.jp) To: wgehrke@dia.uniroma3.it Cc: caml-list@inria.fr Subject: Re: problem with optional arguments In-Reply-To: Your message of "Wed, 20 Sep 2000 12:38:07 +0200" <39C8938F.8DFC8039@dia.uniroma3.it> References: <39C8938F.8DFC8039@dia.uniroma3.it> X-Mailer: Mew version 1.93 on Emacs 20.4 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20000921090825E.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 21 Sep 2000 09:08:25 +0900 From: Jacques Garrigue X-Dispatcher: imput version 980905(IM100) Sender: weis@pauillac.inria.fr From: "Dr. Wolfgang Gehrke" > 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 The point is that optional arguments, when you do not give a default value, are of type [t option] rather than [t], so that [?(a:int)] produces immediately a type clash (int is not compatible with 'a option). The simplest solution is to specify a default: class test2 ?(a:int=2) () = ... Otherwise, you have to explicitely handle the Some and None cases for a. Regards, Jacques Garrigue --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG