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 IAA10051; Wed, 20 Nov 2002 08:48:45 +0100 (MET) 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 IAA10063 for ; Wed, 20 Nov 2002 08:48:44 +0100 (MET) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gAK7mi101653 for ; Wed, 20 Nov 2002 08:48:44 +0100 (MET) Received: from pc8-123 (mail@pc8-123 [129.175.8.123]) by lri.lri.fr (8.11.6/jtpda-5.3.2) with ESMTP id gAK7jpR14236 ; Wed, 20 Nov 2002 08:45:51 +0100 (MET) Received: from filliatr by pc8-123 with local (Exim 3.35 #1 (Debian)) id 18EPYV-0001wx-00; Wed, 20 Nov 2002 08:45:51 +0100 From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <15835.15791.28497.136288@lri.lri.fr> Date: Wed, 20 Nov 2002 08:45:51 +0100 To: Lukasz Lew CC: caml-list@inria.fr Subject: Re: [Caml-list] Is it possible to implement this? In-Reply-To: References: X-Mailer: VM 6.93 under Emacs 20.7.2 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) X-MailScanner: Found to be clean Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Lukasz Lew writes: > > Let's suppose wy have module with such interface > > module X = > type t (*big data structure*) > > add : string -> t > delete : t -> () > > And in the other module i keep X.t list, and i want to keep with each of > them additional data of unknown type [at time of X compilation] You could have a polymorphic type "'a X.t" where 'a stands for the type of the associated data, and provide functions "add_info : 'a -> 'a t -> unit" and "get_info : 'a t -> 'a" in module X. > Other is to keep with every t int identifier as small as possible, to keep > additional data in array, but this solution isn't very good. Following this kind of idea, you could do hash-consing of your X.t values, so that they are allocated only once; doing this, it is easy to associate a unique integer to each value in X.t, which will allow you to build an efficient map over X.t. I already wrote an hash-consing module, available here: http://www.lri.fr/~filliatr/software.en.html (By the way, doing hash-consing has many other advantages such as saving space, providing O(1) equality, ...) Hope this helps, -- Jean-Christophe Filliātre ------------------- 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