Version française
Home     About     Download     Resources     Contact us    
Browse thread
class constraints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Le Normand <rathereasy@g...>
Subject: class constraints
Dear list,
I'm having a little problem understanding constraints in objects. Consider
the following code:

class type foo =
object
  method get_parent : foo
end

class type foo2 =
object
  constraint foo2 = #foo
  method baz : float
  method get_parent : foo2
end

it gives me the following error:

The abbreviation foo2 expands to type < baz : float; get_parent : foo2 >
but is used with type #foo

but foo2 is clearly a subtype of foo. What am I doing wrong? I'm using ocaml
3.10.2
--Jacques Le Normand