Browse thread
[Caml-list] Objects and private methods
-
Patrick M Doane
-
Jacques Garrigue
-
Patrick M Doane
- Jacques Garrigue
-
Patrick M Doane
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2001-12-21 (08:40) |
From: | Jacques Garrigue <garrigue@k...> |
Subject: | Re: [Caml-list] Objects and private methods |
From: Patrick M Doane <patrick@watson.org> > > You cannot convert something from private to public through a coercion > > (this is different from forcing it with an annotation). This is > > because the values are actually different: a private method and a > > public method have different internal representations. > > Are there any papers that I could read over that would give a better sense > for the internal representations? That might help me understand some of > these limitations better. I don't think so, but books like Abadi&Cardelli's Types for Objects would give you an insight on what is safe and what is not. > > On the other hand, you can hide a method through coercions. > > > > class a_impl = object (self) > > method get_b = (self :> b) > > method b = () > > end > > let new_a = (new a_impl :> a) > > Thanks! What then are the advantages to using an annotation instead of a > coercion for signature matching? For example, with a hypothetical syntax > like this: > > class a_impl :> a = object (self) > method get_b = (self :> b) > method b = () > end You can only coerce from type to type, not from signature to signature. Otherwise you would be able to hide a method, and then redefine it with the same name but another type. Such inheritance patterns are not type safe, so you are not allowed to hide a public method at the class level, only at the expression level, where it is safe. Jacques Garrigue ------------------- 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