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 JAA09817; Sat, 5 Jul 2003 09:46:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA10831 for ; Sat, 5 Jul 2003 09:46:53 +0200 (MET DST) Received: from sark.cc.gatech.edu (sark.cc.gatech.edu [130.207.7.23]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h657kpf08849 for ; Sat, 5 Jul 2003 09:46:52 +0200 (MET DST) Received: from gaia.cc.gatech.edu (gaia.cc.gatech.edu [130.207.3.8]) by sark.cc.gatech.edu (8.12.9/8.12.8) with ESMTP id h657kn12026192; Sat, 5 Jul 2003 03:46:50 -0400 (EDT) Received: (from fernando@localhost) by gaia.cc.gatech.edu (8.12.9/8.12.8) id h657kmVt029312; Sat, 5 Jul 2003 03:46:48 -0400 (EDT) Date: Sat, 5 Jul 2003 03:46:48 -0400 From: Fernando Alegre To: Jacques Garrigue Cc: vrotaru@seznam.cz, caml-list@inria.fr Subject: Re: [Caml-list] subtyping, polymorphism, higher order types..... Message-ID: <20030705074648.GA28213@gaia.cc.gatech.edu> References: <3F043EAB.70503@mitre.org> <20030704224521.7db3450f.vrotaru@seznam.cz> <20030705112126Q.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030705112126Q.garrigue@kurims.kyoto-u.ac.jp> User-Agent: Mutt/1.4.1i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alegre:01 gatech:01 caml-list:01 subtyping:01 0900,:01 jacques:01 recognized:99 supertype:01 ad-hoc:01 model:01 exiting:01 restarting:01 encode:01 ocaml:01 coerce:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, Jul 05, 2003 at 11:21:26AM +0900, Jacques Garrigue wrote: > This looks very much like an ocaml object type to me... > Is the absence of labels for fields important? > > Note that you can also encode the above with polymorphism: > > type 'a point = int * int * 'a > type 'a color_point = (int * 'a) point > > The only trouble here is that there is no way to create heterogeneous > collections, since you cannot coerce a [unit color_point] to a [unit > point]. Actually, this just comes from a missing relation in the ocaml > type algebra: the type Obj.t is not recognized as a supertype for all > types. If this were the case then you would be able to write: > let l = [ (p :> Obj.t point); (cp :> Obj.t point) ] > > That would be easy enough to add, but is it that useful? I think yes. That would allow us to avoid creating ad-hoc classes whose only use is such heterogeneous storage. This would save quite a few lines of wrapping code when the basic data structure is a record or a sum type that is extended with a problem-specific type. Currently, the problem is not just heterogeneous collections. In our program, a mutable variable of type 'a model can not be reused to solve one model after another without exiting the program and restarting with a different model, unless we wrap everything in classes. Exiting the program is really inconvenient for interactive user interfaces, and wrapping the code adds many unnecessary lines. So, something like Obj.t coercion would be really useful. Fernando ------------------- 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