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 SAA01693; Wed, 20 Aug 2003 18:19:32 +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 SAA12253 for ; Wed, 20 Aug 2003 18:19:31 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7KGJUf26778 for ; Wed, 20 Aug 2003 18:19:30 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19pVgD-0004bR-00; Wed, 20 Aug 2003 17:19:25 +0100 Date: Wed, 20 Aug 2003 17:19:25 +0100 To: Brian Hurt Cc: Benjamin Geer , caml-list@inria.fr Subject: Re: [Caml-list] does class polymorphism need to be so complicated? Message-ID: <20030820161925.GA17048@redhat.com> References: <3F4396F6.1010404@socialtools.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 unit-:01 upcast:01 freshmeat:01 team's:01 ltd:98 coercion:01 declaring:01 syntax:02 hierarchy:02 business:96 unit:03 wrote:03 obj:03 object:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 20, 2003 at 11:05:35AM -0500, Brian Hurt wrote: > Instead of declaring obj to be printable, why not just declare that it has > a function print? Like: > > class printer = > object > method print (obj: unit>) = obj#print (); > end;; > > This removes the need for a coercion, as it gets around the need to > upcast. Interesting. Am I right in thinking that the unit> type syntax can refer to _any_ object which has a print method, regardless of class hierarchy? This could be quite a fun feature, although I'm not quite sure of the best way to use it ... Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. 'There is a joke about American engineers and French engineers. The American team brings a prototype to the French team. The French team's response is: "Well, it works fine in practice; but how will it hold up in theory?"' ------------------- 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