Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: subtyping and inheritance
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-01-28 (20:00)
From: Hendrik Tews <tews@i...>
Subject: Re: subtyping and inheritance

I don't know how method dispatch is implemented in ocaml. I was
also not able to find a reference about that (is their such?).
Therefore the following is based on some speculation.

   From: Jerome Vouillon <>
   Date: Wed, 27 Jan 1999 15:18:27 +0100
   Subject: Re: subtyping and inheritance
    [concerning covariant method specialization]
   However, it is not possible to apply this extension to Ocaml.  Indeed,
   it requires that methods are chosen depending on the dynamic type of
   their arguments.  But this information is not available in Ocaml.
   There are also difficulties for type inference.

But also in ocaml you choose the method depending on the dynamic
type of object to which it is applied (otherwise late binding
could never work). You only had to repeat this process for all
the arguments of the method which are declared for covariant

The absence of dynamic types applies only to arguments which are
not objects. But since other types (than object types) cannot be
related by the subtype relation, covariant specialization would
never apply for such arguments.

Surly, there would be some difficulties to integrate this
feature. But compare that with the gain! Compare those clumsy
solutions to Markus' problem with the ease of simly overriding
the binary method! Being able to really use binary methods in a
type safe environment would IMHO be worth a lot of effort.