Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Recursive class types (long-standing question ...)
@ 2003-12-30 21:02 William Chesters
  2004-01-10  4:43 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: William Chesters @ 2003-12-30 21:02 UTC (permalink / raw)
  To: caml-list

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
    end

... 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" *)
    end

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-10  4:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 21:02 [Caml-list] Recursive class types (long-standing question ...) William Chesters
2004-01-10  4:43 ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox