Browse thread
[Caml-list] does class polymorphism need to be so complicated?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] does class polymorphism need to be so complicated? |
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: <print: unit->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 <print : unit -> 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