Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Confused: The example on page 48 where (self :> c) does not work
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sarino Suon <doggreen@s...>
Subject: [Caml-list] Confused: The example on page 48 where (self :> c) does not work
Hi, all.

First, let me say that Ocaml is a wonderful language. Its typing
mechanism, though elaborate, appears to be robust, no matter how complex
by data structures become.

There's one problem that defies my understanding, though, and I hope
someone can help. 

I'm trying to understand the example on page 48 of the Ocaml release 3.00
documentation (PDF format). This was to show the case where omitting the
domain of a coercion does not work. Here's the example:

class virtual c = 
	object
		method virtual m:c
	end;;

class c' = 
	object (self) inherit c
		method m = (self :> c)       (* !!! *)
		method m' = 1
	end;;

I don't understand the explanation why the coercion would cause a problem, 
in particular
these two lines of the following paragraph: "On the other hand, in
expression (self :> c) the type of self and the domain of the coercion
above must be unified. That is, the type of the method m in
self (ie. c) is also the type of self. So, the type of self is
c.

It seems, at first blush, that the problem hinges on the special idea of
self-ness. But it seems more involved than this. Can someone help me?

Thank you.

--- Sarino
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr