From: Peng Zang <peng.zang@gmail.com>
To: caml-list@yquem.inria.fr
Cc: Jon Harrop <jon@ffconsultancy.com>
Subject: Re: [Caml-list] An extended comparative study of language support for generic programming
Date: Wed, 10 Feb 2010 21:10:20 -0500 [thread overview]
Message-ID: <201002102110.24083.peng.zang@gmail.com> (raw)
In-Reply-To: <201002110131.00415.jon@ffconsultancy.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Just read the relevant OCaml section, and I see two things that seem strange:
1) From my understanding, the paper appears to say that OCaml has cannot
constrain a function parameter with more than one concept, which is untrue.
Eg.
# class type foo = object method foo : unit end;;
# class type bar = object method bar : unit end;;
# let f ((x:#foo):#bar) = x;;
val f : (< bar : unit; foo : unit; .. > as 'a) -> 'a = <fun>
2) It also says that constraints specified on type parameters may not
determine the actual type. They provide example:
class type conceptA = object
method fn1 : int
end
let algo (x : #conceptA) : int = x#fn2 + 1
And point out the type of parameter x is not just #conceptA, it also has
method fn2. This is true. But although confusing to new users, is hardly
limiting. You can use a sig [A] to ensure the parameter type is correct
(that's what sigs do after all), or you can simple use the close type and
then the open [B].
[A]
include
(struct
let algo (x : #conceptA) : int = x#fn2 + 1
end:sig
val algo : #conceptA -> int
end);;
[B]
let algo (x : conceptA) : int = x#fn1 + 1;;
let algo (x : #conceptA) : int = algo (x:>conceptA);;
Peng
On Wednesday 10 February 2010 08:31:00 pm Jon Harrop wrote:
> On Wednesday 10 February 2010 23:00:44 Raoul Duke wrote:
> > > http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.110.122&rep=re
> > >p1 &type=pdf
> > >
> > :-)
> >
> > http://groups.google.com/group/comp.lang.functional/browse_thread/thread/
> >d6 54fedd6efdf753/3ee82770d5e79402#3ee82770d5e79402
>
> See my response there:
>
> http://groups.google.com/group/comp.lang.functional/msg/2cb15a6281087b04
>
> :-)
>
> I was wondering if anyone here was familiar with this work and/or had
> anything to say about their OCaml solutions and discussion?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
iD8DBQFLc2cQfIRcEFL/JewRAtBaAJ4maHkhrk0oYyDGekgTPkugIb8v1gCbBwg0
QxCm3QBqUR1vrPDB1+aM9bA=
=cQ8r
-----END PGP SIGNATURE-----
prev parent reply other threads:[~2010-02-11 2:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-11 0:06 Jon Harrop
2010-02-10 23:00 ` [Caml-list] " Raoul Duke
2010-02-11 1:31 ` Jon Harrop
2010-02-11 2:10 ` Peng Zang [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=201002102110.24083.peng.zang@gmail.com \
--to=peng.zang@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/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).