caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Didier Remy <remy@morgon.inria.fr>
To: Sarino Suon <doggreen@smoke.propagation.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Confused: The example on page 48 where (self :> c) does not work
Date: 05 Jun 2001 15:06:26 +0200	[thread overview]
Message-ID: <m381yozgjot.fsf@morgon.inria.fr> (raw)
In-Reply-To: Sarino Suon's message of "Thu, 31 May 2001 14:07:56 -0500 (CDT)"

Sarino Suon <doggreen@smoke.propagation.net> writes:

Dear Sarino,

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

This was true in a previous version of the language.  The mecanism for
semi-implicit coercions (_ :> _) has been slightly changed in the current
version of the langage, so as to handle more common cases.  Unfortunately,
the manual has not been changed, acccordingly. (This has already be pointed
out to me, and it will be fixed in the next version.)

The new mechanism handle more common cases, but still does not
accept all of them. For instance, with

     class type c1 =  object ('a) method m : 'a end;;
     class type c2 =  object method m : c2 end;;
     class c = object method m = {< >} method n = 0 end;;

Class types c1 and c2 differ, but object type c1 and c2 are equal.
The following coercion is accepted: 

     (new c' :> c1);;

However, the following, although correct, is rejected

     (new c' :> c2);;

In this case, the explicit (_ : _ :> _) form should be used: 

     (new c' : c' :> c2);;

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


      reply	other threads:[~2001-06-06 20:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-31 19:07 Sarino Suon
2001-06-05 13:06 ` Didier Remy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m381yozgjot.fsf@morgon.inria.fr \
    --to=remy@morgon.inria.fr \
    --cc=caml-list@inria.fr \
    --cc=doggreen@smoke.propagation.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).