From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 305557F249 for ; Tue, 30 Oct 2012 12:41:23 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of bobzhang1988@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of bobzhang1988@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vc0-f182.google.com) identity=helo; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="postmaster@mail-vc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjYCAJG7j1DRVdy2m2dsb2JhbAAqGrEekg8IIwEBAQEBCAkLCRQngh4BAQEEAQEBDwIkCAEbEgoBAQMMBgULDQkEEg8JAwIBAgEREQEFAQoSBg0BBQIBAQ4Qh1EBAw8LLZ0MYgkDjDCBbIEKhQIKGScDClmIdQEFDItphl0DlXSBGo1HP4Qt X-IronPort-AV: E=Sophos;i="4.80,679,1344204000"; d="scan'208";a="179519938" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 30 Oct 2012 12:41:21 +0100 Received: by mail-vc0-f182.google.com with SMTP id fw7so288786vcb.27 for ; Tue, 30 Oct 2012 04:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:newsgroups:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=AvvZ1DCfK8S+5s1iUNcveW2zVNzLf13a/exTxld2Sc0=; b=cDvB5Dtd5Q7lY6N1TLseHibYz7Gp1Tv8mbnXiENse0kmGbz4kXW/FSocv5OyC/O/dT /CfdeAb/cenZhHbYNanfSlHFqu5m92sLVBBnDhrCykFCdzu8lbjx3iTIwCK0q/tYI/bg baxbWuiOfpNYODGfv3G6aOGWGhRuqL7XJMoZAdKEeooCmFxmVI0VOO2e+qjini8ITH0g Fk5LTKI8eLg189bEFyJkUSZ5AJ+nehJpLhk5B+f7Eq20yilTSOlWCmL8R+X1Ct1mVbfq 7/wPfIgO9o3xGNvgte5eGOh3hfe49ISWH2XzXGC9ox4qJ7LzI6vbrY+RljCBHTfL3lgH n4Vg== Received: by 10.52.72.42 with SMTP id a10mr42825154vdv.48.1351597280809; Tue, 30 Oct 2012 04:41:20 -0700 (PDT) Received: from Hongbos-MacBook-Air.local ([66.250.143.158]) by mx.google.com with ESMTPS id g5sm179155vez.6.2012.10.30.04.41.17 (version=SSLv3 cipher=OTHER); Tue, 30 Oct 2012 04:41:18 -0700 (PDT) Message-ID: <508FBCDC.5000104@gmail.com> Date: Tue, 30 Oct 2012 07:41:16 -0400 From: Hongbo Zhang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 Newsgroups: gmane.comp.lang.caml.inria To: Francois Berenger CC: Anton Lavrik , caml-list References: <508F22BD.7010103@riken.jp> <508F9B56.8090806@riken.jp> In-Reply-To: <508F9B56.8090806@riken.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] Re: Why should I use .mli files? Hi all, It's correct that .mli is great for third-party library, but it's not helpful for in-house library and agile-development. Sometimes I have .mli thousands of lines long, it's not fun to sync it up.... That's why I filed a feature request which uses access modifier 'private' like F# http://caml.inria.fr/mantis/view.php?id=5764 If you like the proposal, plz leave a comment to support it ;-) On 10/30/12 5:18 AM, Francois Berenger wrote: > On 10/30/2012 03:12 PM, Anton Lavrik wrote: >> Hi Francois, >> >> I don't use .mli files that much. Granted, I'm a rather casual OCaml >> user, but hey, at least you are not alone :) >> >> I'm surprised by some of the comments you've received. The fact that >> some people tend to practice top-down coding more than others doesn't >> really mean anything. Other people do it differently even regardless >> of the language they use. For me, paper and pencil are far more useful >> than .mli files up until the interfaces converge and stabilize. >> >> In general, .mli files are useful and even essential for libraries and >> large projects. For instance, they allow to clearly (and cleanly) >> define interfaces and help with separate compilation (i.e. to avoid >> recompiling parts). >> >> The biggest inconvenience with .mli files as I see it is that I have >> to repeat myself and make related but slightly different changes in >> two places when I change a module implementation. I would very much >> prefer to declare and document public interfaces next to the >> implementation and have language tooling take care of separate >> compilation and documentation generation. > > Thanks for pointing this out! > > The exact thing that would annoy me if I would adopt .mli files: > repeating myself. > In C, I used a tool call cproto to extract header files out of my .c > implementation code. Then, I just snipped out some parts of the header > I didn't want to make public, if I remember well. > That was not perfect, but at least I did not have to maintain two > files at the same time. > >> OCaml is kind of clumsy in this respect. For example, it does allow to >> specify types for values and function parameters inline. The syntax >> isn't the best, but the feature itself is very useful and I rely on it >> all the time. But when I get to define a type signature for a function >> e.g. in .mli file, I loose the ability to use parameter names and have >> to specify them in the comments. >> >> Overall, I count .mli files as a fairly minor language usability >> issue. Perhaps, it wouldn't be even very hard to fix, for example, by >> allowing something like "[public] val value-name : typexpr" in .ml >> files so that .mli/.cmi files can be generated automatically with >> desired public interfaces. > > I was thinking more about "export" as the keyword of choice, > but the functionality would be exactly the same. > > Best regards, > Francois. > >> Anton >> >> >> On Mon, Oct 29, 2012 at 7:43 PM, Francois Berenger >> wrote: >>> Hello, >>> >>> Here is my stupid question of the day: >>> what's the use of those .mli files? >>> >>> Is it just to separate interface from implementation >>> so that the implementation of a module can be changed >>> without clients of its interface to have to bother? >>> >>> Does it make compilation of large software faster >>> by allowing for more parallelization and maybe later on avoiding to >>> recompile some parts? >>> >>> Usually I program in a pure functional style, so my modules >>> don't carry an internal state. >>> I feel like "if someone want to re-use a function, so be it". >>> If I really want to hide a function that I am afraid people >>> may call in an incorrect manner, I declare it internally >>> to some public function and use it correctly. >>> >>> Also, maybe I only work on toy-size OCaml projects. So, I never >>> bothrered to >>> create any .mli file. >>> I would like to know if I should bother about them. >>> >>> Thanks a lot, >>> Francois. >>> >>> -- >>> Caml-list mailing list. Subscription management and archives: >>> https://sympa.inria.fr/sympa/arc/caml-list >>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>> Bug reports: http://caml.inria.fr/bin/caml-bugs > >