From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 33D11BC37 for ; Fri, 29 May 2009 18:06:17 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar0BAAKlH0pKfS4dimdsb2JhbACNfolXPwEBAQoJDAcPBahvgROPXAEDAgSECAU X-IronPort-AV: E=Sophos;i="4.41,272,1241388000"; d="scan'208";a="27035539" Received: from yw-out-2324.google.com ([74.125.46.29]) by mail2-smtp-roc.national.inria.fr with ESMTP; 29 May 2009 18:06:16 +0200 Received: by yw-out-2324.google.com with SMTP id 9so3299235ywe.3 for ; Fri, 29 May 2009 09:06:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ifjRscsnXAMYvQa1+K7c1sfD868LAAzAC01bx+c9wds=; b=LlJoPIz2CuvsefgTXYRHUgzqA7ci6IpJnt9013M7LIqhP5pv5DQRG82yaaELk2dIkw 2O7281WS45Btwubp+Le++9ayzDEkdNRmB4mkIjC29ZlejlFJ2KzDFBgXjRQQ6kwwx6lK BCmBZ0kd/2+cgNf9kyXKbNLn7YXhvLbZoxqJA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Sc7KS48/tGfCe3Rjfb1SqucSxrHZNxoaXXSYMBQNFF0pnAn1P3i7OQkEflpRsrUN1f VkPwkiwk8RX8z0Bu53uc1lkq+Bs6p6qVZBEl3OYS7ijZHnRWOUBLOb+RvzIILayaxL0x cglt6Bxn/v6Sb7vXFpGmbYBKXQekmYWtpHPZ0= MIME-Version: 1.0 Received: by 10.100.168.9 with SMTP id q9mr2607915ane.144.1243613175799; Fri, 29 May 2009 09:06:15 -0700 (PDT) In-Reply-To: <407261.14507.qm@web111505.mail.gq1.yahoo.com> References: <407261.14507.qm@web111505.mail.gq1.yahoo.com> Date: Fri, 29 May 2009 12:06:15 -0400 Message-ID: <9d3ec8300905290906j675f6406je81420afdcc9473d@mail.gmail.com> Subject: Re: [Caml-list] Width subtyping From: Till Varoquaux To: Dario Teixeira Cc: Jacques Carette , caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; subtyping:01 escapes:01 ocaml:01 checker:01 variants:01 o'caml:01 cheers:01 beginner's:01 ocaml:01 bug:01 2009:98 polymorphic:01 beginners:01 wrote:01 typing:01 There must be something that escapes me.... This seems to be an example where ocaml objects really shine because of the structural typing (i.e. an object is defined by the its structure): type t1 =3D type t2 =3D type t3 =3D < b: int; c: int; d: int > let v1 : t1 =3D object method a =3D 1; method b =3D 2; method c =3D3 end let v2 : t2 =3D object method a =3D 1; method b =3D 2; method c =3D3 ; meth= od d =3D 4 end let v3 : t3 =3D object method b =3D 2; method c =3D3 ; method d =3D 4 end let get_a x : int =3D x#a let _ =3D get_a v1 (** ok*) let _ =3D get_a v2 (** ok *) let _ =3D get_a v3 (** rejected by the type checker*) On Fri, May 29, 2009 at 11:45 AM, Dario Teixeira wrote: > > Hi, > >> The dual of sums is products.=C2=A0 Open (labelled) sums >> are "polymorphic variants".=C2=A0 Their duals are open >> (labelled) products are "rows" (which O'Caml already >> supports, through its objects). > > Yes, as I mentioned, for some classes of this particular problem the obje= ct > system can be put to good use -- when there is a clear tree for inheritan= ce, > for example. =C2=A0Unfortunately that is always not the case; there are p= roblems > where you would end up with a tangled web of multiple inheritances just f= or > the sake of avoiding duplicating methods. > > Cheers, > Dario > > > > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >