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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 96312BC0A for ; Thu, 15 Mar 2007 23:39:54 +0100 (CET) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2FMdqBR006971 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 15 Mar 2007 23:39:54 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1HRybY-0007Ez-00; Thu, 15 Mar 2007 22:39:28 +0000 Date: Thu, 15 Mar 2007 22:39:28 +0000 To: ian Cc: caml-list@inria.fr Subject: Re: [Caml-list] Style and organization of code Message-ID: <20070315223928.GA25205@furbychan.cocan.org> References: <45F87661.4020504@softhome.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45F87661.4020504@softhome.net> User-Agent: Mutt/1.5.9i From: Richard Jones X-Miltered: at concorde with ID 45F9CB38.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; unreadable:01 ocaml:01 compiler:01 mli:01 sig:01 struct:01 mli:01 instinct:98 wrote:01 caml-list:01 functions:01 functions:01 define:01 ian:03 module:03 On Wed, Mar 14, 2007 at 05:25:37PM -0500, ian wrote: > Say I have a function called "solveHardProblem". Ack! studlyCaps is horrible and unreadable (I know - I'm currently involved in a project which uses them). Try "solve_hard_problem" instead. > solveHardProblem relies on > several helper functions, which are not going to be useful to any other > functions in the program. So, my first instinct would be to define all the > helpers using let blocks within the definition of solveHardProblem. > > But that would make the definition of solveHardProblem really long -- several > screens of text -- which I've been taught to avoid. You've been taught wrong. There are some studies that show that long functions actual reduce error rates - see Steve McConnell's book Code Complete for references. > Is it wrong to use a module to hide those functions if the module > signature will contain only that of solveHardProblem? Not wrong at all. > And say you DO choose to use a module... The OCaml documentation > says that the compiler can automatically infer the signature without > the need to create a .mli file for it. Does anyone actually use > that feature in practice, or is creating a sig hard-wired to the act > of creating a struct? You don't need to create a separate .mli (in fact, you sometimes can't). Rich. -- Richard Jones Red Hat