Browse thread
An extended comparative study of language support for generic programming
-
Jon Harrop
-
Raoul Duke
-
Jon Harrop
- Peng Zang
-
Jon Harrop
-
Raoul Duke
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Peng Zang <peng.zang@g...> |
| Subject: | Re: [Caml-list] An extended comparative study of language support for generic programming |
-----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-----