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 RAA28858; Thu, 12 Aug 2004 17:21:59 +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 RAA02263 for ; Thu, 12 Aug 2004 17:21:58 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7CFLvmL021268 for ; Thu, 12 Aug 2004 17:21:57 +0200 Received: from ibm3.cicrp.jussieu.fr (ibm3.cicrp.jussieu.fr [134.157.15.3]) by shiva.jussieu.fr (8.12.11/jtpda-5.4) with ESMTP id i7CFL5e1028208 for ; Thu, 12 Aug 2004 17:21:05 +0200 (CEST) X-Ids: 166 Received: from ibm1.cicrp.jussieu.fr (ibm1.cicrp.jussieu.fr [134.157.15.1]) by ibm3.cicrp.jussieu.fr (8.8.8/jtpda/mob-V8) with ESMTP id RAA123390 for ; Thu, 12 Aug 2004 17:19:51 +0200 Received: from localhost (fernande@localhost) by ibm1.cicrp.jussieu.fr (8.8.8/jtpda/mob-v8) with ESMTP id RAA675992 for ; Thu, 12 Aug 2004 17:19:29 +0200 X-Authentication-Warning: ibm1.cicrp.jussieu.fr: fernande owned process doing -bs Date: Thu, 12 Aug 2004 17:19:28 +0200 (DST) From: Diego Olivier Fernandez Pons X-X-Sender: fernande@ibm1 To: caml-list@inria.fr Subject: Re: [Caml-list] Managing a polymorphic environment In-Reply-To: <1092323198.411b877e22214@mouette.ens-lyon.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 411B8B15.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at shiva.jussieu.fr with ID 411B8AE1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; pons:01 pons:01 etu:99 caml-list:01 encapsulate:01 incremented:01 foo:01 coerced:01 foo:01 hashed:01 hashtbl:01 hash:01 fernandez:01 fernandez:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Bonjour, You are breaking type transparency (or have I misunderstood ?). Otherwise you can always encapsulate your types (in a module) and generate a unique integer (with a reference incremented every time you call the generating function) > let x = new foo_int 10 "the number of elements in the knapsack" > Env.add x (*x is coerced to foo, we forget it's an int*) > let c = new foo_float "the total cost of the knapsack" > Env.add c > > x#print > c#print let say Env is a set with hashed keys Env.add : 'a -> unit type color = Blue | White | Red let print_color = function x -> let message = Env.get_string (Hashtbl.hash x) in match x with | Blue -> print_string message ^ "blue" | etc. # print_color;; - color -> unit = let x = Blue Env.add x print_color x -- Here the problem is 'let' -- Diego Olivier ------------------- 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