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 B95087F249 for ; Tue, 30 Oct 2012 15:47:08 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain.bardou@inria.fr) identity=pra; client-ip=178.32.98.231; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="romain.bardou@inria.fr"; x-sender="romain.bardou@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain.bardou@inria.fr) identity=mailfrom; client-ip=178.32.98.231; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="romain.bardou@inria.fr"; x-sender="romain.bardou@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mo3.mail-out.ovh.net) identity=helo; client-ip=178.32.98.231; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="romain.bardou@inria.fr"; x-sender="postmaster@mo3.mail-out.ovh.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsUAAE3nj1CyIGLnmWdsb2JhbAAqGsNrAQEBAQEICwsHFCeCHwEFMgEFQBELIRYPCQMCAQIBRRMGAgKIAgQHLaw2kDuLd4M5gyQDlXWBGpIY X-IronPort-AV: E=Sophos;i="4.80,679,1344204000"; d="scan'208";a="179551696" Received: from 19.mo3.mail-out.ovh.net (HELO mo3.mail-out.ovh.net) ([178.32.98.231]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 Oct 2012 15:47:08 +0100 Received: from mail171.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo3.mail-out.ovh.net (Postfix) with SMTP id 4C622FF95A3 for ; Tue, 30 Oct 2012 15:57:09 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 30 Oct 2012 16:47:07 +0200 Received: from gwvisitors.lsv.ens-cachan.fr (HELO ?172.31.81.30?) (romain%bardou.fr@138.231.81.8) by ns0.ovh.net with SMTP; 30 Oct 2012 16:47:05 +0200 Message-ID: <508FE869.3070603@inria.fr> Date: Tue, 30 Oct 2012 15:47:05 +0100 From: Romain Bardou User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.9) Gecko/20121014 Icedove/10.0.9 MIME-Version: 1.0 To: caml-list@inria.fr X-Ovh-Mailout: 178.32.228.3 (mo3.mail-out.ovh.net) References: <508F22BD.7010103@riken.jp> <026F32A8-2790-4CDD-A839-58655A8074CA@first.in-berlin.de> In-Reply-To: <026F32A8-2790-4CDD-A839-58655A8074CA@first.in-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 16746916691086903840 X-Ovh-Remote: 138.231.81.8 (gwvisitors.lsv.ens-cachan.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: 0 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehfedrudekucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecunecuhfhrohhmpeftohhmrghinhcuuegrrhguohhuuceorhhomhgrihhnrdgsrghrughouhesihhnrhhirgdrfhhrqeenucffohhmrghinhepihhnrhhirgdrfhhrnecujfgurhepkfffhfgfggfvufhfjggtgfesthekrgdttdefud X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehfedrudekucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecunecuhfhrohhmpeftohhmrghinhcuuegrrhguohhuuceorhhomhgrihhnrdgsrghrughouhesihhnrhhirgdrfhhrqeenucffohhmrghinhepihhnrhhirgdrfhhrnecujfgurhepkfffhfgfggfvufhfjggtgfesthekrgdttdefud X-Validation-by: romain.bardou@inria.fr Subject: Re: [Caml-list] Why should I use .mli files? Le 30/10/2012 15:32, Oliver Bandel a écrit : > > > Am 30.10.2012 um 07:12 schrieb Anton Lavrik: > >> 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. > > > ocamlc -i > is your friend... > > Ciao, > Oliver > > ocamlc -i is not that useful IMO. It's not incremental: if you modify a file and want to update the .mli, ocamlc -i will not help, because using it directly would remove all comments and abstractions. I don't even find it useful to start a new .mli file, because usually when I do that, I don't have the implementation yet. Even if I have the implementation, so much work will be needed after ocamlc -i that it's just easier to start from scratch, write the interface that I think I should have, and compare with the existing one. It allows to check that what I have implemented is what I actually want. The work I'm talking about is the following. - Abstract stuff. This involves removing some values, some types, some type definitions, adding "private" keywords, replacing types by their abstraction. - Documentation. This involves writing some ocamldoc and categorizing stuff in sections. I know a lot of programmers are lazy and do not put ocamldoc in their .mli but this is even more important than the .mli itself, IMO. Related: http://caml.inria.fr/mantis/view.php?id=5777 Now, it does not mean that nothing could be done. Probably an approach a la Pascal, with an "interface" section and an "implementation" section in the same file, could be used to avoid some code duplication. But that would not help with separate compilation. Maybe ocaml should provide something like: include type t in sig Which would mean "copy-paste the definition of t from the .mli". Cheers, -- Romain Bardou