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 RAA31792; Fri, 8 Feb 2002 17:37:07 +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 RAA32549 for ; Fri, 8 Feb 2002 17:37:06 +0100 (MET) Received: from mandelbrot.house (host217-35-37-89.in-addr.btopenworld.com [217.35.37.89]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g18Gb5D01807 for ; Fri, 8 Feb 2002 17:37:05 +0100 (MET) Received: by mandelbrot.house (Postfix, from userid 1001) id 4870163; Fri, 8 Feb 2002 16:37:00 +0000 (GMT) Date: Fri, 8 Feb 2002 16:37:00 +0000 From: Ceri Storey To: Ryan Tarpine Cc: caml-list@inria.fr Subject: Re: [Caml-list] Allowing many types Message-ID: <20020208163700.GA1452@mandelbrot.house> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Feb 07, 2002 at 09:29:44PM -0500, Ryan Tarpine wrote: > type Primitive = > | PInt of int > | PString of string > | PFloat of float > ... > The problem is, I know that I will need new types in the future besides > these. It's an object-oriented language, and I would like to add classes > that manage things like Tk. Every object has a variable of type Primitive > that it stores its value in. Is it possible to somehow allow other types, > like Tk's widgets, without changing the definition of Primitive to include > them and recompiling everything? I've been trying to do something similar with something i'm writing, and the only thing i could come up with is to store data in an object, and then subclass it. The problem here is that once the object has been coerced to the general type, it cannot be coerced back again. ie: if you subclass the object to say, impliment integers, then it's not possible for it to be coerced back to the integer type so you can retreive / act on the value. (withoug using Obj.magic, that is) If anyone has any good ideas, I'd be happy to hear about them too. -- Ceri Storey http://pkl.net/~cez/ vi(1)! postfix(7)! pie(5)! ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr