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 WAA13607; Thu, 21 Aug 2003 22:24:04 +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 WAA08622 for ; Thu, 21 Aug 2003 22:24:02 +0200 (MET DST) Received: from rabelais.socialtools.net (rabelais.socialtools.net [81.2.94.243]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7LKO2f16043 for ; Thu, 21 Aug 2003 22:24:02 +0200 (MET DST) Received: by rabelais.socialtools.net (Postfix, from userid 108) id 987AB23314; Thu, 21 Aug 2003 21:24:01 +0100 (BST) Received: from socialtools.net (chaucer.socialtools.net [81.2.94.242]) by rabelais.socialtools.net (Postfix) with ESMTP id 574C023311; Thu, 21 Aug 2003 21:24:00 +0100 (BST) Message-ID: <3F452978.1040805@socialtools.net> Date: Thu, 21 Aug 2003 21:20:08 +0100 From: Benjamin Geer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-gb, en, fr, it MIME-Version: 1.0 To: brogoff@speakeasy.net Cc: Jacques Garrigue , "caml-list@inria.fr" Subject: Re: [Caml-list] does class polymorphism need to be so complicated? References: In-Reply-To: X-Enigmail-Version: 0.76.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-2.6 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA,X_ACCEPT_LANG autolearn=ham version=2.54 X-Spam-Checker-Version: SpamAssassin 2.54 (1.174.2.17-2003-05-11-exp) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 brogoff:01 burdensome:01 coerce:01 speakeasy:01 coercion:01 coercion:01 compile:02 objects:02 objects:02 string:03 string:03 wrote:03 let:04 complicated:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk brogoff@speakeasy.net wrote: > I think the burden is very slight, but I have no problem at all with using > functions outside of objects. Realistic implementations would provide > coercion functions for every base class you want to coerce to, perhaps > named something like "as_base_class_name". Using the exmaple you give in > another message, we get something like this [...] Thanks for the example; I think I can live with the approach you propose. :) I agree with you (and Scott Meyers) about functions outside of objects being a good thing, as long as they're doing something useful, and not just working around syntactical problems. Or at least as long as I don't have to write a large number of them. With the approach you suggest, it looks like I only need one coercion function per base class, which I agree isn't too burdensome: > let as_connection o = (o : #connection :> connection);; I'm still curious to know why the example I gave (returning a mysql_connection from a method that was typed to return a #connection) didn't compile, though ("This method has type string -> mysql_connection which is less general than 'a. string -> (#connection as 'a)"). Ben ------------------- 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