Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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

> > 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:  FAQ:
To unsubscribe, mail  Archives: