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 DAA04550; Tue, 6 Aug 2002 03:03:55 +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 DAA04730 for ; Tue, 6 Aug 2002 03:03:53 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from www.duonix.com ([210.113.163.221]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g7613oP24248 for ; Tue, 6 Aug 2002 03:03:51 +0200 (MET DST) Received: from hama ([192.168.0.254]) by www.duonix.com (8.12.5/8.11.6) with SMTP id g7617eQG054278; Tue, 6 Aug 2002 10:07:40 +0900 (KST) (envelope-from shoh@duonix.com) X-Authentication-Warning: www.duonix.com: Host [192.168.0.254] claimed to be hama Message-ID: <001e01c23ce5$2aaf8b00$fe00a8c0@hama> From: "SooHyoung Oh" To: "Jacques Garrigue" Cc: References: <000501c23c4f$2b781c50$fe00a8c0@hama> <20020805183043B.garrigue@kurims.kyoto-u.ac.jp> Subject: Re: [Caml-list] Weak type, Open type Date: Tue, 6 Aug 2002 10:04:08 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Thanks for you reply. Fortunately, I'm using Ocaml 3.05 and polymophic method works well. But coding as your comments on weak type makes an error. See followings. > From: "SooHyoung Oh" > > > While I've studying design pattern with ocaml, > > I made the followding 3 classes (PART1): > > (1) class virtual entry: base class > > (2) class file: subclass of "entry" class > > (3) class dir: subclass of "entry" class > > > > I made some code using these classes on top level and it's ok. (PART 2). > > While I translate the top level code into new class definition (PART3), it > > makes some error. > > The error message is on (PART 4). > > > > It seems that (PART2) is weak type and (PART 3) is open type. > > Not weak: file_list has a weak type variable, but it gets immediatly > instanciated to entry; and add is really polymorphic. > > > [Q 1] Is (PART2) is correct? I don't know why it doesn't make type error. > Yes. What's wrong? > Note that your #entry is meaningless, since it is immediatly > instanciated to entry. You could as well write entry list from the > beginning, or nothing at all. > The types of (PART2) are val file_list : _#entry list ref = {contents = []} val add : #entry -> unit = After removing '#': val file_list : entry list ref = {contents = []} val add : _#entry -> unit = Using "entry" instead of "#entry" produces the following: This expression has type file = < file_size : unit -> int; name : unit -> string > but is here used with type < dir_size : unit -> int; name : unit -> string > Only the second object type has a method dir_size [Deleted ...] ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners