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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 0E9267F249 for ; Tue, 30 Oct 2012 02:04:33 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pdgroves@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="pdgroves@gmail.com"; x-sender="pdgroves@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of pdgroves@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="pdgroves@gmail.com"; x-sender="pdgroves@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.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=mail4-smtp-sop.national.inria.fr; envelope-from="pdgroves@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: Al4CAGknj1DRVdy2m2dsb2JhbAA+BrBpiSoBiG0IIwEBAQEBCAkLCRQngh4BAQEDARICLAEbEgsBAwELBgUEBwcTISIBEQEFAQoEDgYTEhCHUQEDCQYLnGJiCQOMMIJ2hGQKGScDClmIdQEFDItpJoY3A4hZjRuBGo1HFimCUIFf X-IronPort-AV: E=Sophos;i="4.80,675,1344204000"; d="scan'208";a="160824174" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 30 Oct 2012 02:04:08 +0100 Received: by mail-vc0-f182.google.com with SMTP id fw7so10288106vcb.27 for ; Mon, 29 Oct 2012 18:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=luvEBzBMRdJWAadVpnkk4AeStkwOlIefEgHJXS7df10=; b=0fXGOEdC2BAwLpKDi67dcVfs86bxh52q8fr1/dKNKaRVmCXf+dQ14A7ATDKfioheBu Z3NvkXlg+Ri6H+FwmlGE7Z47VTPMkjMg/P272KaXShmFjLrjy/EQFmcG98gNUsHMOonF l1doYs8bVytTxWDlH6GdQjlcwcdgwBAmuLwoTD6rYVqk0RdJSX4rYsu5a7a3spk9VJul KrhztKUVZwBkGGfiJ+ntl2Nf93Edf1Wm8eqgcnBVUCjW+gOWISadF7CZQ2XzMsFd5L7z R3P21gI5AuzKbrQkBVijTSqq0hZPSnpVPLL3KBFfMSPI9slQZlxYuyBnRWFetoPFByBU KDOQ== MIME-Version: 1.0 Received: by 10.52.180.5 with SMTP id dk5mr41493514vdc.45.1351559047643; Mon, 29 Oct 2012 18:04:07 -0700 (PDT) Received: by 10.58.205.236 with HTTP; Mon, 29 Oct 2012 18:04:07 -0700 (PDT) In-Reply-To: <508F22BD.7010103@riken.jp> References: <508F22BD.7010103@riken.jp> Date: Mon, 29 Oct 2012 20:04:07 -0500 Message-ID: From: Peter Groves To: Francois Berenger Cc: caml-list Content-Type: multipart/alternative; boundary=bcaec5196789ed807d04cd3c5cf6 Subject: Re: [Caml-list] Why should I use .mli files? --bcaec5196789ed807d04cd3c5cf6 Content-Type: text/plain; charset=ISO-8859-1 If you only do small projects, you're probably doing things right by ignoring the .mli files. Languages like Ruby and Python don't have signature files and that's part of what makes them good for scripting tasks. But since you asked, here's why I use mli files almost always: 1) The signature files are my "architecture." When I start implementing something substantial, I'll first make the .mli files for the modules I think I'll need. I can pretty quickly refactor them until they make sense semantically and compile against each other. It's not unusual for me to change an .mli file 10 times before I bother starting to implement it. After that, I just use the unimplemented methods as my todo list. 2) Documentation. Sometimes I have a module with a 1000 line .ml file and 30 line .mli file (with comments). Much easier to refer to the .mli to reuse it's methods. -Peter 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 > --bcaec5196789ed807d04cd3c5cf6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable If you only do small projects, you're probably doing things right by ig= noring the .mli files. Languages like Ruby and Python don't have signat= ure files and that's part of what makes them good for scripting tasks.<= div>
But since you asked, here's why I use mli files almost a= lways:

1) The signature files are my "archite= cture." When I start implementing something substantial, I'll firs= t make the .mli files for the modules I think I'll need. I can pretty q= uickly refactor them until they make sense semantically and compile against= each other. It's not unusual for me to change an .mli file 10 times be= fore I bother starting to implement it. After that, I just use the unimplem= ented methods as my todo list.

2) Documentation. Sometimes I have a module with a 1000= line .ml file and 30 line .mli file (with comments). Much easier to refer = to the .mli to reuse it's methods.

-Peter

On Mon, Oct 29, 2012 at 7:43 PM, Francois Be= renger <berenger@riken.jp> 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 recompi= le 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 t= o create any .mli file.
I would like to know if I should bother about them.

Thanks a lot,
Francois.

--
Caml-list mailing list. =A0Subscription management and archives:
ht= tps://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners<= /a>
Bug reports:
http://caml.inria.fr/bin/caml-bugs

--bcaec5196789ed807d04cd3c5cf6--