From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id oBSEGg1h022633 for ; Tue, 28 Dec 2010 15:16:42 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEALN/GU1QRFuw/2dsb2JhbACkMHO/MYVKBA X-IronPort-AV: E=Sophos;i="4.60,239,1291590000"; d="scan'208";a="83530322" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 28 Dec 2010 15:16:37 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.69) (envelope-from ) id 1PXaLm-0006zi-Fc; Tue, 28 Dec 2010 14:16:30 +0000 Date: Tue, 28 Dec 2010 14:16:30 +0000 From: "Richard W.M. Jones" To: Lauri Alanko Cc: caml-list@inria.fr Message-ID: <20101228141630.GA26760@annexia.org> References: <20101228140247.GB12021@melkinpaasi.cs.helsinki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101228140247.GB12021@melkinpaasi.cs.helsinki.fi> User-Agent: Mutt/1.5.18 (2008-05-17) Subject: Re: [Caml-list] Avoiding ml/mli code duplication On Tue, Dec 28, 2010 at 04:02:47PM +0200, Lauri Alanko wrote: > This does the job, but I'm not quite satisfied. It feels wrong that I > have to define a functor when I will only ever apply it once. Also, > the "include module type of" is a recent feature, and it's hard to > believe there's no solution to this problem before OCaml 3.12. I think the solution (use of functors) is worse than the problem. Like OO style, functors make it very hard to examine code and understand which piece of code is going to run when you call some function. > I'd appreciate any suggestions for better solutions. Just preprocess your code with /bin/cpp, using #include to include a common file. Or don't worry about the repeated code too much. Rich. -- Richard Jones Red Hat