Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Protected methods
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <alex@b...>
Subject: Re: [Caml-list] Protected methods
Gerd Stolpmann wrote:
> No, you cannot restrict the type of classes by signatures.
> The only way I know to protect a method is to define an opaque
> type that is hidden by the signature, e.g.
> 
> sample.ml:
> 
> type protector = unit
> 
> class a =
> object
>   method m () = ...
>   ...
> end
> 
> sample.mli:
> 
> type protector
> 
> class a :
> object
>   method m : protector -> XXX
>   ...
> end
> 
> You cannot call m from other modules because you cannot create values
> for the type "protector".
> 
> Gerd

Effective, definitely, but practical? Is this not supposed 
to be a feature of any general purpose object oriented language?

Anyway, for the meantime I'll keep the method public, and 
make sure I don't use it anywhere except where it makes 
sense, and I'll wait for some more insight from the developers.

Thank you very much, Gerd.

Alex

-------------------
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