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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-03 (10:58)
From: Stefano Zacchiroli <zack@c...>
Subject: Re: [Caml-list] Open types and methods
On Sun, Nov 03, 2002 at 11:30:36AM +0100, J?r?me Marant wrote:
>   I know that I cannot use open types as method parameter types,
>   like:
>   method foo (w : #mother) = ....
>   So, how can I pass to a method an object of a given class or
>   of its inherited classes, i.e. how to work this limitation
>   around?

Just define the method as:

  method foo (w: #mother) = ...

And cast the object when invoking foo:

  obj#foo (son :> mother)


Stefano Zacchiroli - undergraduate student of CS @ Univ. Bologna, Italy
zack@cs.unibo.it | ICQ# 33538863 | http://www.cs.unibo.it/~zacchiro
"I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant!" -- G.Romney
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