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
[Caml-list] Recursive class types (long-standing question ...)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-12-30 (21:06)
From: William Chesters <williamc@p...>
Subject: [Caml-list] Recursive class types (long-standing question ...)
Here's something I've wondered about for a while and just encountered again.
How come this class ..

    class virtual ['a] c = object
      method virtual b: bool c

... gets a constraint 'a = bool?  I.e. for instance this doesn't compile:

    class virtual ['a] c = object
      method virtual b: bool c
      method virtual i: int c
          (* "This type int should be an instance of type bool" *)

Note that the following does work in C++:

    template <class a>
    struct c {
      virtual c<bool> b() = 0;
      virtual c<int> i() = 0;

I guess there are workarounds but it seems unnecessary that ML should find
recursive parameterised classes harder than C++?

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: