Version française
Home     About     Download     Resources     Contact us    
Browse thread
storing object in record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michael <micha-1@f...>
Subject: storing object in record

it seems that I'm not able to figure out how to do  this:

class baseclass = object(this)
  method asBase = (this :> baseclass)
(* ... *)	
end;;

class ex = object inherit baseclass method name = "ex" end

type state_rec = { mutable state:  'a. #baseclass as 'a };;


this gives an error:

let x = new ex;;

{ state = x };;
Error: This field value has type ex which is less general than
         'a. #baseclass as 'a

or:

{ state = x#asBase };;
Error: This field value has type baseclass which is less general than
         'a. #baseclass as 'a

or:

type state_rec = { mutable state:  'a. < asBase: baseclass;..> as 'a };;
gives:
Error: Unbound type parameter ..


what I'm missing here?

cheers
 Michael