Browse thread
[Caml-list] Passing self to a new object
-
Andrew Lawson
-
Jacques Garrigue
-
Andrew Lawson
- Jacques Garrigue
-
Andrew Lawson
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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.
Cheers,
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