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] Passing self to a new object
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-30 (08:10)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Passing self to a new object
From: Andrew Lawson <andrew@absentis.com>

> > The general solution to this is to first define a class type:
> >   class type xyz_t = object ('self)
> >      method 
> >        btnNew : ...
> >        ...
> >      end
> 	Well this gives me an excuse to start playing with types and
> interfaces  anyway.  Is this a 'known problem, will be sorted
> eventually' or a 'just live with it' sort of thing?

Well, this was delayed for a very long time, but I'm starting to think
that we should really do something about it.

> > Then change the code in btnNew to
> >   new abc (self :> xyz_t)
> 	 Casting! and here was I giving a C++ programmer some abuse
> about this last week :)

No, this is a coercion. This is perfectly type-safe (and checked at
compile time).  This is needed for type inference. Languages with
explicit type information, like Java, do it silently.


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