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.4 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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0C180BBAF for ; Thu, 20 Nov 2008 14:42:08 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.33,639,1220220000"; d="scan'208";a="20177846" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with ESMTP; 20 Nov 2008 14:42:07 +0100 Received: by ausone.inria.fr (Postfix, from userid 501) id F007A2AF4535; Thu, 20 Nov 2008 14:41:12 +0100 (CET) Content-Type: text/plain; charset=UTF-8 Subject: RE: [Caml-list] open Module (not?) considered harmful From: Nicolas Pouillard To: David Allsopp , Stefano Zacchiroli , Caml_mailing list References: <1227002178.6170.25.camel@Blefuscu> <200811182330.03947.jon@ffconsultancy.com> <1227076192.6290.7.camel@Blefuscu> <4b5157c30811190146l2c6a5e2cv4a085bcc14ae5f4@mail.gmail.com> <20081119211124.51610ae9@alcazar.inria.fr> <1227172839-sup-5973@ausone.inria.fr> <20081120103303.GA25346@annexia.org> <20081120104914.GA14355@usha.takhisis.invalid> <000001c94b03$4f55d4e0$ee017ea0$@com> <1227185953-sup-4761@ausone.inria.fr> In-Reply-To: <1227185953-sup-4761@ausone.inria.fr> Date: Thu, 20 Nov 2008 14:41:12 +0100 Message-Id: <1227188375-sup-8502@ausone.inria.fr> User-Agent: Sup/git X-Spam: no; 0.00; zacchiroli:01 printf:01 swapped:01 refactor:01 iirc:01 ocaml:01 syntax:01 foo:01 trivial:01 camlp:01 syntax:01 trivial:01 camlp:01 wiki:01 20,:98 Excerpts from Nicolas Pouillard's message of Thu Nov 20 14:01:53 +0100 2008: > Excerpts from David Allsopp's message of Thu Nov 20 11:29:44 UTC 2008: > > On 20 November 2008 10:49, Stefano Zacchiroli wrote: > > > On Thu, Nov 20, 2008 at 10:33:03AM +0000, Richard Jones wrote: > > > > Encouraging developers to open modules is also usually a bad idea, > > > > except in very limited circumstances (hello Printf). > > > > > > Why? You and others failed me to convince of this. Or, better, I'm > > > sure there are problems with that, but they just show deficiencies > > > inherited from other parts of the language. > > > > Consider > > > > open Array;; > > open List;; > > > > (* Hundreds of lines of code *) > > > > length [];; > > That's not a good example, because I consider the shadowing above as > an ambiguity on certain identifiers. Don't confuse short names and ambiguous > names. > > > The code is now is brittle in terms of the order of the open statements at > > the top of the file and will fail to compile if they're swapped. Of course, > > if you don't care about that kind of subtle refactoring error then open is > > completely fine. Personally, I find that kind of brittleness irritating - > > and it also has the potential to waste a huge amount of time if you have to > > refactor the code. > > > > Whether you find code less readable with or without module names is of > > course a matter taste and IIRC, OCaml 3.11 .annot files contain the > > necessary information to expand them so there could be a nice editor plugin > > to expand or remove module paths... > > > > > > The most straightforward solution to this problem to me looks like > > > > providing a syntax equivalent like "from Module import foo, bar" > > > > which selectively imports only some identifiers from a given module. > > > > Which, for values only, is of course a trivial camlp4 extension... and could > > be generalised to include type declarations and so on with only a little > > more work. The .NET languages have a syntax for selectively importing > > classes from a namespace rather than the entire namespace (and it's > > different from Java's in that you can rename the class while you do it). > > I have a trivial camlp4 extension for that actually if someone is interested, > feel free to ask. Given the crowd of people wanting it, I've added a link [1] to the camlp4 wiki [2] :) [1] http://aloxe.inria.fr/darcs/pa_import [2] http://brion.inria.fr/gallium/index.php/Camlp4_contributions -- Nicolas Pouillard aka Ertai