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 4FCF07F249 for ; Tue, 30 Oct 2012 07:12:40 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alavrik@piqi.org) identity=pra; client-ip=209.85.215.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="alavrik@piqi.org"; x-sender="alavrik@piqi.org"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alavrik@piqi.org) identity=mailfrom; client-ip=209.85.215.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="alavrik@piqi.org"; x-sender="alavrik@piqi.org"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f54.google.com) identity=helo; client-ip=209.85.215.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="alavrik@piqi.org"; x-sender="postmaster@mail-la0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqoCAIVvj1DRVdc2k2dsb2JhbABEsSGSGQgjAQEBAQkJCwkUBCOCHgEBAQQSAloLEAsLDQ0hIhIBBQEKEgYTEhCHUgMPC5x7YgkDjhyGPwOJXot1hl0DiFmNG4EajUcWKYQvgXs X-IronPort-AV: E=Sophos;i="4.80,677,1344204000"; d="scan'208";a="179470898" Received: from mail-la0-f54.google.com ([209.85.215.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 30 Oct 2012 07:12:19 +0100 Received: by mail-la0-f54.google.com with SMTP id e12so7610067lag.27 for ; Mon, 29 Oct 2012 23:12:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=VopjQAvGDf+Xt0NlSggoJBqMmBysroZ+DnaEks0USyQ=; b=I0J8SpxrC67pvUvlKHP28fV2ExsDWNXagxCnZGmT5xeqAh+HyJLKJWOUqyJJnSIDET EQUqokWBMKCD1cTkXwBbWV7PtIh1oheWgyb/AkjHtqLcqtGbuu4vQLgt86mwKm5iJ24A KK85FSIt8FSNUhGrHSw0L/Azo+s7Uqxv5jefEWDfkl6v81gmT7uFMT0+cTC+jmIuzb/w pJzcH79dkr1hVspkx7/U6woWtmRU5XMHkr159prce4+4FEQ+SWOPazJJK5t83F3so+JZ AeY2FSkDjccEgoReYM0quq3aFgh3xNtzBi/pb12V/oTxzsN2Rf2/cfNle+YkLyosROtH mOnw== MIME-Version: 1.0 Received: by 10.112.48.200 with SMTP id o8mr12769732lbn.96.1351577539293; Mon, 29 Oct 2012 23:12:19 -0700 (PDT) Received: by 10.152.104.104 with HTTP; Mon, 29 Oct 2012 23:12:19 -0700 (PDT) X-Originating-IP: [98.201.107.96] In-Reply-To: <508F22BD.7010103@riken.jp> References: <508F22BD.7010103@riken.jp> Date: Tue, 30 Oct 2012 01:12:19 -0500 Message-ID: From: Anton Lavrik To: Francois Berenger Cc: caml-list Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkSXYqY/RdhuhIFsUaC8VrVB08l4E1FJKEllMmlvM1+EuRHWp4LUoADu2Z5ipiGsEMdbYME Subject: Re: [Caml-list] Why should I use .mli files? 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. 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. 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