caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: micha-1@fantasymail.de
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] object type error
Date: Mon, 19 Sep 2005 21:20:59 +0900 (JST)	[thread overview]
Message-ID: <20050919.212059.41628279.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <200509191044.36763.micha-1@fantasymail.de>

From: Michael Wohlwend <micha-1@fantasymail.de>

> ( type xxx is a class type and the other class implements this interface)
> 
> ----------------------Error:
> This expression has type
>   < (* many methods *); .. >
> but is here used with type xxx
> Self type cannot be unified with a closed object type
> ---------------------
> I try to get rid of them by adding random type declarations which I mostly 
> don't understand :-), but that's not the solution.
> 
> What is the reason for that message?

It means that type inference results in unifying the type of self
(either from a named self, a {< .. >} expression, or a type
annotation) to an explicit object type. To allow classes to be
extended, the type of self must be left polymorphic.
You can sometimes avoid it by using a coercion (self :> xxx), but this
doesn't work if xxx was not defined in advance, of if it contains
contravariant occurences.
I stop here: you already realize this is a rather hairy problem.

Since there can be many causes, I need to see your code to understand
where the problem comes from.
Another solution if you don't need to inherit from the object you are
defining, is to use an immediate object, as it is allowed to have a
closed type; at least you won't get the above message.

Jacques Garrigue


      reply	other threads:[~2005-09-19 12:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-19  8:44 Michael Wohlwend
2005-09-19 12:20 ` Jacques Garrigue [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=20050919.212059.41628279.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=micha-1@fantasymail.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).