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
class constraints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-03-27 (14:06)
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 =
  method get_parent : foo

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

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
--Jacques Le Normand