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: | Brian Hurt <bhurt@s...> |
| Subject: | Re: [Caml-list] does class polymorphism need to be so complicated? |
On Wed, 20 Aug 2003, Benjamin Geer wrote:
> class printer =
> object
> method print (obj : printable) = obj#print()
> end ;;
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.
Brian
-------------------
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