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 NAA21003; Tue, 24 Jun 2003 13:15:20 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 NAA21286 for ; Tue, 24 Jun 2003 13:15:19 +0200 (MET DST) Received: from saul.cis.upenn.edu (SAUL.CIS.UPENN.EDU [158.130.12.4]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5OBFIX23460 for ; Tue, 24 Jun 2003 13:15:19 +0200 (MET DST) Received: from saul.cis.upenn.edu (localhost [127.0.0.1]) by saul.cis.upenn.edu (8.12.9/8.12.9) with ESMTP id h5OBFHmV025184 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 24 Jun 2003 07:15:18 -0400 (EDT) Received: (from bywang@localhost) by saul.cis.upenn.edu (8.12.9/8.12.9/Submit) id h5OBFH5U025183 for caml-list@inria.fr; Tue, 24 Jun 2003 07:15:17 -0400 (EDT) From: Bow-Yaw Wang Message-Id: <200306241115.h5OBFH5U025183@saul.cis.upenn.edu> Subject: [Caml-list] copy of parametrized object To: caml-list@inria.fr Date: Tue, 24 Jun 2003 07:15:17 -0400 (EDT) X-Mailer: ELM [version 2.4 PL23-upenn3.3] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; bow-yaw:01 bywang:01 val:01 unsound:01 feasible:01 int:01 polymorphic:01 instantiated:02 objects:02 classes:03 obj:03 object:03 explanation:04 let:04 defining:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I'd like to know how to make independent copies of parameterized objects. Consider the following example: # class ['a] t = object method id (x:'a) = x end;; class ['a] t : object method id : 'a -> 'a end # let o = new t;; val o : '_a t = # let p = Oo.copy o;; val p : < id : '_a -> '_a > = # o#id 1;; - : int = 1 After defining a simple parameterized class t, I create an object o of type '_a t and make p as a copy. After the type '_a is instantiated to int, I'd expect p to retain its type < id : '_a -> '_a >. However, # p;; - : < id : int -> int > = So my questions are: 1. Is there a way to make a copy of o so that it can be instantiated differently? 2. If not, is there any type-theoretic explanation? I'm just curious if it may make type system unsound. I'm aware of polymorphic methods. Unfortunately, the project I'm working on uses parameterized classes. Using polymorphic methods doesn't seem to be feasible at the moment. :( Thanks in advance, Bow-Yaw ------------------- 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