Overriding with subtypes

From: Gert Smolka (smolka@ps.uni-sb.de)
Date: Mon Aug 30 1999 - 18:54:30 MET DST


To: caml-list@inria.fr
From: Gert Smolka <smolka@ps.uni-sb.de>
Subject: Overriding with subtypes
Date: Mon, 30 Aug 1999 18:54:30 +0200

It should be ok to override a method of type t
with a method of a subtype of t. In fact,
that happens in

class c = object(self) method a = self end
class c' = object(self) inherit c method a = self method b = 1 end

since c' is a proper subtype of c. This is accepted by
Ocaml. However,

class d = object method a = new c end
class d' = object inherit d method a = new c' end

is rejected. Why? I would expect that this is a
limitation that is due to the type inferencer.

Gert Smolka



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:24 MET