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
method name collision ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-25 (22:58)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] method name collision ?
From: briand@aracnet.com

> I'm getting the following error 
> The method point has type 'a -> 'b but is expected to have type
>   x:int -> y:int -> unit
> for this code :
> method point p0 =
>  etc..
> The error makes sense, as in, I know that it is colliding with a
> method defined in the drawable class.
> However I am inheriting the class using :
>   inherit GDraw.drawable ?colormap w as drawable
> It seems to me that the method I am defining, self#point, and the
> method in drawable, i.e. drawable#point, are distinct and therefore
> I should not be seeing this error message ?

The "as drawable" doesn't mean that the methods are distinct: you can
still call all inherited methods from the outside, and even through
This only allows you to access the old definition of a method, if you
want to extend it incrementally.

method point ~x ~y =
  ...  drawable#point ~x ~y ...

Jacques Garrigue