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=2.1 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 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 10B0CBB84 for ; Fri, 15 Aug 2008 19:10:07 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhICABtVpUjAXQIniGdsb2JhbACRRj4BAQEPIJp4hmYBAoNp X-IronPort-AV: E=Sophos;i="4.32,216,1217800800"; d="scan'208";a="28248483" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Aug 2008 19:10:06 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m7FHA61b002562 for ; Fri, 15 Aug 2008 19:10:06 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhMBAO1TpUjRVcitlGdsb2JhbACRRj4BAQEBCQMKBxEDmnaGZgECg2k X-IronPort-AV: E=Sophos;i="4.32,216,1217800800"; d="scan'208";a="14018738" Received: from wf-out-1314.google.com ([209.85.200.173]) by mail2-smtp-roc.national.inria.fr with ESMTP; 15 Aug 2008 19:07:16 +0200 Received: by wf-out-1314.google.com with SMTP id 25so1252699wfa.0 for ; Fri, 15 Aug 2008 10:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=E92G1J7mSn+y+kP3pH+DNc+bCB+j4HTqPUwmHfYSidI=; b=JiLzWMJLk4jd2gxrtbcNe4Jk9g6w9KfUi+C4/GpupGkV20PRei/ZYNfpFnXgK+0wQr R0qid9SjsRuzL2c1IXgJ3HyN59H3Xe+ZEgdx/IA1YRayJ7aVjdxFwQI2SCytbk4GBQFI 2jEx4LEGtdalUuStRsX4e2qjBSDeZJK7FKjyg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=XblNrLjswnBX2OaE4LRBxyTO94AUJXgzm86uQz4caDTqShLokhR4pqJ6AuHN+T71Hc UDt4dUc52Tm577+85IHdvdSidDQFTjSeXlq3kdf5PFnZk4ywEz1z5spSXiL/jgLPzppj ZEeBWQaakV0y+e10XZCHKnNo4ehOBnZTu7TaE= Received: by 10.142.70.11 with SMTP id s11mr1056832wfa.293.1218820035657; Fri, 15 Aug 2008 10:07:15 -0700 (PDT) Received: by 10.142.105.11 with HTTP; Fri, 15 Aug 2008 10:07:15 -0700 (PDT) Message-ID: <2b7b425b0808151007t57f89671s91727e328b888f8e@mail.gmail.com> Date: Fri, 15 Aug 2008 19:07:15 +0200 From: "=?ISO-8859-1?Q?J=E9r=E9mie_Lumbroso?=" Sender: jeremie.lumbroso@gmail.com To: caml-list@inria.fr Subject: Re: Multiple value declaration in .mli file MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Google-Sender-Auth: dae54393d8122d9a X-Miltered: at concorde with ID 48A5B86E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; mli:01 foo:01 baz:01 foo:01 val:01 toplevel:01 sig:01 val:01 sig:01 struct:01 mismatch:01 struct:01 mismatch:01 dumped:01 toplevel:01 Hello, > I guess you need it to mirror the value shadowing on the implementation s= ide: > include Foo > let bar =3D baz > > This is legal if Foo already defines bar, and most of the time desired an= d > useful. > In the interface file you'll want to write : > include FOO (* Foo's signature *) > val bar : ... Actually, this is untrue. I think that up until recently (3.09.2?), what you describe would have caused an error (one of the many annoying things about signatures in ML languages that prompted that clever paper by Ramsey et al.). In the latest version, 3.10.2, however, this does not produce an error, but reaches a very peculiar state: # module type FOO =3D sig val foo : int end;; module type FOO =3D sig val foo : int end # module type BAR =3D sig include FOO val foo : string end;; module type BAR =3D sig val foo : int val foo : string end # module Bar : BAR =3D struct let foo =3D 1 end;; Signature mismatch: Modules do not match: sig val foo : int end is not included in BAR Values do not match: val foo : int is not included in val foo : string # module Bar : BAR =3D struct let foo =3D "1" end;; Signature mismatch: Modules do not match: sig val foo : string end is not included in BAR Values do not match: val foo : string is not included in val foo : int # module Bar : BAR =3D struct let foo =3D Obj.magic 1 end;; module Bar : BAR # Bar.foo;; Erreur de segmentation (core dumped) Indeed, since foo is simultaneously an int and a string, the only way to create a module conforming to the BAR signature, is to make foo an 'a. I think this is what the original poster was referring to, and it is indeed a bug. Noteworthy: # module Bar : BAR =3D struct let foo =3D Obj.magic "1" end;; module Bar : BAR # Bar.foo;; - : string =3D "1" I am (blind) guessing that at some point, someone decided to make redefining symbols in signatures legal, but overlooked a quirk in the way OCaml stores signatures. Regards, J=E9r=E9mie