caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jerome Vouillon <vouillon@clipper.ens.fr>
To: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
Cc: caml-list@margaux.inria.fr
Subject: Re: Questions about class types
Date: Wed, 11 Dec 1996 14:16:31 +0100 (MET)	[thread overview]
Message-ID: <Pine.SUN.3.95.961211135357.24246A-100000@vedette> (raw)
In-Reply-To: <199612101110.MAA11392@ithif18.inf.tu-dresden.de>


Hello,

> In ocaml I could hide all the additional objects in a module
> implementation. But so far it is not possible to hide methods via
> signature matching.

It is definitively not possible to hide methods in a class.  When a
method is redefined, it must keep the same type. The reason is that
other methods of the same class might invocate it, and thus expect it
to have a certain type. But if a method were hidden, its previous type
would also be hidden, and there would be no way to enforce a
redefinition of this method to have the right type.

> But I still don't understand the type error I got:
> 
>    Values do not match:
>      val newb : unit -> b
>    is not included in
>      val newb : unit -> < init : unit; .. >
> 
> If b does not match  < init : unit; .. >  then the type cast in 
> 
> #  let newb () : < init : unit; .. > = ((new b ()) : < init : unit; .. >)
> 
> should produce an error. On the other side if the type cast is
> valid, then the types should match.

Type < init : unit; .. > is more general than type
b = < init : unit; f : unit > (the ellipsis is an unamed type
variable). So, your type cast produces no error (these two types can
be unified), but you cannot expect a function of type unit -> b to be
considered as having the more general type
  unit -> < init : unit; .. >.

Regards,

Jerome






  reply	other threads:[~1996-12-11 15:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-21 13:57 Hendrik Tews
1996-11-21 17:10 ` Christian Boos
1996-12-10 11:10   ` Hendrik Tews
1996-12-11 13:16     ` Jerome Vouillon [this message]
     [not found] <199612171154.MAA03264@arthur.u-strasbg.fr>
1996-12-17 16:06 ` Jerome Vouillon

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=Pine.SUN.3.95.961211135357.24246A-100000@vedette \
    --to=vouillon@clipper.ens.fr \
    --cc=caml-list@margaux.inria.fr \
    --cc=tews@tcs.inf.tu-dresden.de \
    /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).