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.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 0890ABB84 for ; Thu, 14 Aug 2008 18:25:56 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqwCAL34o0jZkraAmmdsb2JhbACCMy6LbIMyAQEBAQEIBQgHEQOjXoFV X-IronPort-AV: E=Sophos;i="4.32,210,1217800800"; d="scan'208";a="13995782" Received: from web28108.mail.ukl.yahoo.com ([217.146.182.128]) by mail2-smtp-roc.national.inria.fr with SMTP; 14 Aug 2008 18:25:55 +0200 Received: (qmail 43330 invoked by uid 60001); 14 Aug 2008 16:25:55 -0000 Received: from [195.83.213.140] by web28108.mail.ukl.yahoo.com via HTTP; Thu, 14 Aug 2008 16:25:54 GMT X-Mailer: YahooMailWebService/0.7.218 Date: Thu, 14 Aug 2008 16:25:54 +0000 (GMT) From: mohamed iguernelala Subject: Multiple value declaration in .mli file To: caml-list@yquem.inria.fr MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1158347441-1218731154=:42946" Message-ID: <186665.42946.qm@web28108.mail.ukl.yahoo.com> X-Spam: no; 0.00; mli:01 ocaml:01 mli:01 val:01 val:01 bool:01 ocaml:01 bool:01 compiles:01 compiles:01 int:01 int:01 define:02 define:02 declaration:02 X-Attachments: cset="utf-8" cset="utf-8" --0-1158347441-1218731154=:42946 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello everyone, We've just noticed that Ocaml permits to declare a value several times in a= n .mli file. For example : We can write in a.mli ---- val f : int val f : bool ---- and it compiles. But if we define a value f in a.ml it compiles only when f's value is 'a. From external files, only the second declaration is visible. Then why Ocaml allows multiple declaration for the same value in .mli files. Are there any reason to allow it ? ------ David & Mohamed=0A=0A=0A _____________________________________________= ________________________________ =0AEnvoyez avec Yahoo! Mail. Une boite mai= l plus intelligente http://mail.yahoo.fr --0-1158347441-1218731154=:42946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
=0A=0A=0A
=0AEnvoy=C3=A9 avec Yahoo! Mail.
Une boite mail plus intelligente.
--0-1158347441-1218731154=:42946-- 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 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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 6D353BB84 for ; Fri, 15 Aug 2008 19:38:43 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhICAE5cpUjAXQIniGdsb2JhbACRRj4BAQEPIJs4hmEBAoNp X-IronPort-AV: E=Sophos;i="4.32,216,1217800800"; d="scan'208";a="16151818" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Aug 2008 19:38:43 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m7FHcgrN003417 for ; Fri, 15 Aug 2008 19:38:43 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhMBAAVcpUjRVciqlGdsb2JhbACRRj4BAQEBCQMKBxEDmzWGYQECg2k X-IronPort-AV: E=Sophos;i="4.32,216,1217800800"; d="scan'208";a="16020635" Received: from wf-out-1314.google.com ([209.85.200.170]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Aug 2008 19:36:37 +0200 Received: by wf-out-1314.google.com with SMTP id 25so1263880wfa.0 for ; Fri, 15 Aug 2008 10:36:35 -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:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=j1o7OnLDqIxcW6cEyESm36yzvZOhQyPPbv1OCaIphQs=; b=q00ukh/U0gaUj/o3CWv6/8YaH7s/P2JrBPgWfwjJ1VM/qGL1KZ+56HfCXUTyh3qnkf Qf21u2XoteYFa/RZ7xr7Tka4A6pZGjIJ++2Iovm0Jp8Ndq5EB19nguuJqetAZHBzJ9h6 hdlrCMFc+avtgZCRDLI9UenxJ9BR3ri31gBE8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=Gf1+ZAJnudNiLwkNfnxnpHo7Tf1rzFXWX6vLLPEtBcm0AxvANXcOARCCEtJLCK5uwT hHKiy8iP+MkHEaTT0myc46ZP3IjRizolCX7+MAJuJkbC1Xa2GNRoXFXlJ/upXTsXM9EY 4hMSMIQVIiWtNgsHtOPNy8ag4IIqA0AiS1rA4= Received: by 10.142.214.11 with SMTP id m11mr1069077wfg.95.1218821795857; Fri, 15 Aug 2008 10:36:35 -0700 (PDT) Received: by 10.142.105.11 with HTTP; Fri, 15 Aug 2008 10:36:35 -0700 (PDT) Message-ID: <2b7b425b0808151036q18dec4a5pb9af5d6fcaea3f02@mail.gmail.com> Date: Fri, 15 Aug 2008 19:36:35 +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 In-Reply-To: <2b7b425b0808151007t57f89671s91727e328b888f8e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <2b7b425b0808151007t57f89671s91727e328b888f8e@mail.gmail.com> X-Google-Sender-Auth: 2afa000b1411cebc X-Miltered: at concorde with ID 48A5BF22.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 sig:01 toplevel:01 wrote:01 signatures:01 defines:01 int:01 int:01 declaration:02 On Fri, Aug 15, 2008 at 7:07 PM, J=E9r=E9mie Lumbroso wrote: >> I guess you need it to mirror the value shadowing on the implementation = side: >> include Foo >> let bar =3D baz >> >> This is legal if Foo already defines bar, and most of the time desired a= nd >> 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 Ramse= y > et al.). I may have gotten carried away! :-) I was thinking of type definitions, and have no idea if the behavior for values was the same. # module type Foo =3D sig type t =3D int end;; module type Foo =3D sig type t =3D int end # module type Bar =3D sig include Foo type t =3D string end;; Multiple definition of the type name t. Names must be unique in a given structure or signature. J=E9r=E9mie
Hello everyone,

We've jus= t noticed that Ocaml permits to declare a value several times in an .mli fi= le.

For example : We can write in a.mli

----
val f : intval f : bool
----

and it compiles.

But if we define a va= lue f in a.ml it compiles only when f's value is 'a.
From external files, only the second declaration is visible. Then why Ocaml allows multiple declaration for the same value in .mli files. Are there any reason to allow it ?

------
David & Mohamed