caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: Mattias Waldau <mattias.waldau@abc.se>
Cc: Caml-List <caml-list@inria.fr>
Subject: Re: Why can't I use val mover : < move : int -> unit; .. > list -> unit ?
Date: Wed, 10 Jan 2001 20:58:27 +0100 (MET)	[thread overview]
Message-ID: <Pine.GSO.4.04.10101102050580.17728-100000@clipper.ens.fr> (raw)
In-Reply-To: <HDEEKOMJILGEIHIMAPCDCEFFDNAA.mattias.waldau@abc.se>

On Wed, 10 Jan 2001, Mattias Waldau wrote:

> In the example below I have two separate classes with no common 
> super class. Both classes have a method 'move'.
> 
> I have no problem using the function main below that can an 
> arbitrary 'objects with move defined'. However, when I try to 
> expand the example to list of objects with move defined, I 
> cannot use this function.
> 
> How can I use the function 'mover'? How do I coerce to 
> objects with move defined? 

The problem is that you can't put objects of different types in the same
list, and there is no implicit coercion to a subtype in OCaml. As
explained in the manual (section 3.10), you have to use an explicit
subtyping, for instance:

mover [(p :> p1d_1); q]

or:
type m = < move : int -> unit >
mover [(p :> m); (q :> m)]


-- 
  Alain Frisch



  parent reply	other threads:[~2001-01-11  9:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-10 12:39 Mattias Waldau
2001-01-10 19:16 ` Brian Rogoff
2001-01-11  9:07   ` Mattias Waldau
2001-01-11 12:26     ` Michel Schinz
2001-01-11 13:09     ` Sylvain BOULM'E
2001-01-10 19:58 ` Alain Frisch [this message]
2001-01-11  9:29 ` Sylvain BOULM'E

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.GSO.4.04.10101102050580.17728-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=caml-list@inria.fr \
    --cc=mattias.waldau@abc.se \
    /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).