English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
class subtyping
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-17 (15:00)
From: nakata keiko <keiko@k...>
Subject: class subtyping
I have a question about subtyping between classes.

Why an instance of class a can not coerced into type b?

class a = object (self : 'a)
  method f (x : 'a) = x#g
  method g = 0

class b = object 
  inherit a
  method h = 1

let x = ((new b) :> a) 

I got an error for the last statement.

I am reading the work on extension problem found at 
I am curious to know how ocaml compiler judges subtyping relation 
involving self types.