caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocaml, objects, classes, type ascription, virtual methods
@ 2011-05-23  7:50 Dmitry Grebeniuk
  2011-05-23  8:29 ` Matthieu Dubuget
  2011-05-23 10:11 ` Jacques Garrigue
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Grebeniuk @ 2011-05-23  7:50 UTC (permalink / raw)
  To: caml-list

Hello.

  I have a base class with virtual methods and an extended classes
where these methods are implemented.
  When I'm ascribing type "base" to class "ext", I get an error:

=============
        OCaml version 3.13.0+dev3 (2011-03-07)

# class virtual base = object method virtual m : unit end;;
class virtual base : object method virtual m : unit end
# class ext : base = object method m = () end;;
Characters 6-43:
  class ext : base = object method m = () end;;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This class should be virtual. The following methods are undefined : m
#
=============

  Is it the expected behaviour?
  It would be more useful to allow to constrain "class ext" by type "base"
while providing an implementation for virtual methods.
  For now, I'm omitting the type ascription, but then I have less guarantees
about extended classes' compatibility/interchangeability.

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

end of thread, other threads:[~2011-05-23 10:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23  7:50 [Caml-list] ocaml, objects, classes, type ascription, virtual methods Dmitry Grebeniuk
2011-05-23  8:29 ` Matthieu Dubuget
2011-05-23  8:40   ` Dmitry Grebeniuk
2011-05-23  9:08     ` Lauri Alanko
2011-05-23  9:21       ` Dmitry Grebeniuk
2011-05-23 10:11 ` Jacques Garrigue
2011-05-23 10:25   ` Dmitry Grebeniuk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).