From: Damien <Damien.Pous@ens-lyon.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] functors and objects
Date: Thu, 5 Feb 2004 14:45:06 +0100 [thread overview]
Message-ID: <20040205144506.57a47fc7.Damien.Pous@ens-lyon.fr> (raw)
In-Reply-To: <20040205181845V.garrigue@kurims.kyoto-u.ac.jp>
On Thu, 05 Feb 2004 18:18:45 +0900 Jacques Garrigue wrote:
> Because instanciation/specialization only works for values, not for
> types.
> This is reasonable enough: once you have defined a type, you may use
> it both in covariant and contravariant positions, so allowing to
> specialize it would be unsound.
> (So, yes, in the long run this is a soundness problem.)
I don't see the point :-(
module type O =
sig
type " t :> o "
end
can be read as
module type O =
sig
type ellipsis (* abstract *)
type t = " <o; ellipsis> "
end
therefore, a functor F(M: O) cannot create objects of type t without the
help of M.
module F(M: O) =
struct
(* correct invariant use *)
let l: M.t list ref = ref []
(* correct covariant use *)
let get: unit -> M.t list = fun () -> !l
(* correct contravariant use *)
let add: M.t -> unit = fun o -> l := o : !l
(* unsound has type `unit -> o' but not `unit -> M.t' *)
let unsound() = new object method react = () end
end
where is it wrong ?
damien
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-02-05 13:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-03 18:06 Damien
2004-02-03 19:37 ` Matt Gushee
2004-02-03 19:39 ` [Caml-list] functors and objects' Matt Gushee
2004-02-03 20:26 ` Damien Pous
2004-02-04 2:57 ` [Caml-list] functors and objects Jacques Garrigue
2004-02-05 8:55 ` Damien
2004-02-05 9:18 ` Jacques Garrigue
2004-02-05 13:45 ` Damien [this message]
2004-02-06 1:30 ` Jacques Garrigue
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=20040205144506.57a47fc7.Damien.Pous@ens-lyon.fr \
--to=damien.pous@ens-lyon.fr \
--cc=caml-list@inria.fr \
/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