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
[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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners