From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 6770DBC37 for ; Thu, 11 Feb 2010 03:10:28 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmcBAAP2ckvRVdPLkGdsb2JhbACTNIc+CBUBAQEBCQkMBxMDIK5fCoFAhGOIcgEBAwWCA4JNBIMTiB8 X-IronPort-AV: E=Sophos;i="4.49,448,1262559600"; d="scan'208";a="56783075" Received: from mail-yw0-f203.google.com ([209.85.211.203]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Feb 2010 03:10:27 +0100 Received: by ywh41 with SMTP id 41so1273938ywh.0 for ; Wed, 10 Feb 2010 18:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date :user-agent:cc:references:in-reply-to:content-type :content-transfer-encoding:content-disposition:message-id; bh=UsU2xounprbYFZY5A83TtVObjtcT4GRB7voaOkRpd1o=; b=RWQ7km1AyspWvZx0jNBstKcL+rjH+XBNPp6nwQm7XZQZEPz8hMxhGdTmO18u9ohNTe Ph7ijP+bt8+Zh2hDDDhx4sHhUHhlavbqBYN7lZeTEVRoHMkZqm1JN1jUOf9Nmu5o+fKh hPsOpH2T2OHBYEpQ6si7HeRgLDjL/dmP0ajfQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to :content-type:content-transfer-encoding:content-disposition :message-id; b=DUFW8ImRt/PxNhIE7FM1tOY+OVmTN3ggwUv3mLBjE7Dx0cVxwCxP+d+9eR0T0P7LWo dl19446MOvN7z1Duc3HUATF3slPK1fWsM1JDSgGPVfyXCmoNb3lb9hfyketSsZLrC8vC MlRprnc+Mc1sP6+FFi83D6rFyjUyxFQssHOic= Received: by 10.150.117.12 with SMTP id p12mr3659367ybc.254.1265854226632; Wed, 10 Feb 2010 18:10:26 -0800 (PST) Received: from ?192.168.0.102? (c-98-230-173-131.hsd1.ga.comcast.net [98.230.173.131]) by mx.google.com with ESMTPS id 20sm725076ywh.32.2010.02.10.18.10.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Feb 2010 18:10:25 -0800 (PST) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] An extended comparative study of language support for generic programming Date: Wed, 10 Feb 2010 21:10:20 -0500 User-Agent: KMail/1.9.10 Cc: Jon Harrop References: <201002110006.40579.jon@ffconsultancy.com> <91a2ba3e1002101500x75733e88x2f582a2354742ce4@mail.gmail.com> <201002110131.00415.jon@ffconsultancy.com> In-Reply-To: <201002110131.00415.jon@ffconsultancy.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201002102110.24083.peng.zang@gmail.com> X-Spam: no; 0.00; hash:01 ocaml:01 ocaml:01 foo:01 foo:01 val:01 sig:01 sigs:01 struct:01 sig:01 val:01 peng:98 peng:98 psu:98 wrote:01 -----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 = 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-----