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] Objects and private methods
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-12-21 (03:02)
From: Patrick M Doane <patrick@w...>
Subject: [Caml-list] Objects and private methods
I'm having some trouble getting the following type of structure to

  class type a = object method get_b : a end

         and b = object method b : unit end

  class a_impl =
  (object (self)
    method get_b = (self :> b)
    method private b = ()
  end : a)

This produces the error message:

  The class type object method b : unit method get_b : b end
  is not matched by the class type a
  The public method b cannot be hidden

The basic idea is that the class 'a_impl' implements 'b' privately. This
seems like something that should be possible to do.  I suspect that the
coercion of self to 'b' is causing the problem here.

I would have expected the failure to occur when coercing to type 'b' as
the method is declared private (which does not match the signature).

Any thoughts?


Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr