Version française
Home     About     Download     Resources     Contact us    
Browse thread
extending a functional updater implicitly publicizes sub-updater method?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <remi.vanicat@g...>
Subject: Re: [Caml-list] extending a functional updater implicitly publicizes sub-updater method?
On Tue, 22 Mar 2005 20:18:06 +0100 (CET), Marc Herbert
<marc.herbert.1@ml.free.fr> wrote:
> [This is a shameless repost of
>   http://groups.google.com/groups?selm=d1coe3%242l%241%40wolfberry.srv.cs.cmu.edu
>  Looks like comp.lang.ml is more comp.lang.sml than comp.lang.caml...]

For an unknown reason, my answer (message-id:
<87r7ieuf54.dlv@vanicat.homelinux.org>) that have been post on the
neuf.fr news server does not appear on google, so I will suppose that
it hasn't propagate, and I will re-answer here

> I don't understand why my private subupdater is "made public implicitly"
> 
> Example inspired from
>  http://caml.inria.fr/ocaml/htmlman/manual005.html#ss:functional-objects
> This sample code is quite similar to extending the constructor of a
> superclass.
> 
> class functional_point =
>    object
>      val x = 0
>      method private forward = {< x = x + 1 >}
>    end;;
> 
> class functional_color_point =
>    object
>      inherit functional_point as super
>      val color = 0
> 
>      (* color_forward is made implicitly public ?!? *)
>      method private color_forward = {< color = color + 1 >}
> 
>      method private forward = super#forward#color_forward
>    end;;

In ocaml, you can only call a private method on self. super#forward
is not self, so you cannot call the color_forward method on it. Then
as a private method can be made public latter, ocaml make the method
public to make the code correct, and give you this warning.