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 CB974BC57 for ; Sun, 28 Mar 2010 18:38:20 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoBAAMjr0tDww+RkWdsb2JhbACDGYt5L4FOii4BAQEBCQsKBxEDH60LN4FphECIegEEBAGBJoJsagSDHg X-IronPort-AV: E=Sophos;i="4.51,323,1267398000"; d="scan'208";a="59832080" Received: from web111503.mail.gq1.yahoo.com ([67.195.15.145]) by mail4-smtp-sop.national.inria.fr with SMTP; 28 Mar 2010 18:38:10 +0200 Received: (qmail 51632 invoked by uid 60001); 28 Mar 2010 16:38:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1269794288; bh=PIpABwa59V6Mpku/ia6sswjr7xKcRrtDhynAliEBNQs=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=MZRnwrP8oeY7+CXy2E0UR4eV665qSgjG/H7Qoeo5MUSI5YqaO33mQC+6qIR2GIcDbP/4BIKN9yIwKAV9xlkn1WisXgU9Ncp15Sg75afdToJGuynCHM8/Qfva91g+wAVAg3o/UcFuz5fUw9pbD8Jrn4b/ED6fuqAz8G+4RljVNLM= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=eVnfwy6M/kLOiQgD7qJRcu+fwaj/h+4xkmoL9YyyqGGXH2FBKcHeRKD7KPmyUCqa1GllKxr7K5Qtz4nF0Off4bUggfnxBYCg89zu/1ruMCLUVdztwSppvfcQpY/dJvjpJzB9d7vMm7p4K5ONeVrU2H2xXrXimqsoxguxNyXH/sc=; Message-ID: <61102.44294.qm@web111503.mail.gq1.yahoo.com> X-YMail-OSG: UQd86pgVM1n8qhfTNQuDfTg67gkWFA3RxKisM2PEjpic2wU m.Bxo.c7yAFRfRKprRI4upRtCScDND6Ct_gH_5J1Qk25sjtG8ULL62dpPUwh GO9S1QC14Ht1RT_GLw50QMCl0_nbUO4bAwLq5N.8TOFtBazrln3k8dKg9ntX ygspxdKQcb50K8THWWxfGuRWZzgp.ms.Xpjw3kdiIgsqwhNAcFboxjKIZ3uD rV1Np7Yk_jauvm7bvHihjBbH8IT8SbAJC2phwZzA1Obs8sNSBIKKkqGWl07o jgTniVoGAoiNB0N5s7IeuSUFMKwYncjrJJ2a1ktybziLP8tEOva5S6e0- Received: from [213.205.71.61] by web111503.mail.gq1.yahoo.com via HTTP; Sun, 28 Mar 2010 09:38:07 PDT X-Mailer: YahooMailClassic/10.0.8 YahooMailWebService/0.8.100.260964 Date: Sun, 28 Mar 2010 09:38:07 -0700 (PDT) From: Dario Teixeira Subject: Structural subtyping problem To: caml-list@yquem.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; subtyping:01 subtyping:01 ocaml's:01 intuitively:01 compiler:01 annotations:01 coercions:01 coercions:01 rec:01 compile:01 int:01 emulate:01 width:97 parameter:02 parameter:02 Hi,=0A=0AI'm using the structural subtyping aspects of Ocaml's object syste= m to emulate width=0Asubtyping. I've come across a problem which does not = type-check, though intuitively=0Ait seems correct. I reckon that the compi= ler may need some help in the form of type=0Aannotations and/or coercions, = though their exact shape elludes me.=0A=0AA simple nonsensical example that= illustrates the problem is listed below; the=0Atype-checking error occurs = in function "step1", where the optional parameter "story"=0Ais used as an o= bject of type "< title:string; .. >". In function "step3", this=0Aparamete= r "story" is actually instantiated with objects of type "< title:string >"= =0Aand "< title:string; count:int >".=0A=0AAnyway, am I correct in assuming= this should be feasible? And if so, what coercions=0Aare required to make= this compile?=0A=0AThanks in advance!=0ABest regards,=0ADario Teixeira=0A= =0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=0A=0Alet rec step1 ?story () =3D match story with=0A=09| Some s -= > step2 s#title=0A=09| None -> step2 "title1"=0A=0A=0Aand step2 title =3D= =0A=09let story =3D=0A=09=09object=0A=09=09=09method title =3D title=0A=09= =09=09method count =3D 0=0A=09=09end=0A=09in step3 ~story=0A=0A=0Aand step3= ~story =3D match story#count with=0A=09| 0 ->=0A=09=09step1 ~story ()=0A= =09| 1 ->=0A=09=09let story =3D=0A=09=09=09object=0A=09=09=09=09method titl= e =3D "title2"=0A=09=09=09end=0A=09=09in step1 ~story ()=0A=09| _ ->=0A=09= =09true=0A=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=0A=0A=0A=0A=0A