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.5 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 73987BBAF for ; Thu, 20 Nov 2008 12:30:09 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUBAH/ZJElRZ90wkWdsb2JhbACNL4YsAQEBAQkLCgcRA74Vgnw X-IronPort-AV: E=Sophos;i="4.33,639,1220220000"; d="scan'208";a="17407030" Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Nov 2008 12:30:02 +0100 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20081120113002.BUDK1717.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com>; Thu, 20 Nov 2008 11:30:02 +0000 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20081120113002.IRTM19264.aamtaout01-winn.ispmail.ntl.com@romulus.metastack.com>; Thu, 20 Nov 2008 11:30:02 +0000 Received: from Countertenor ([149.254.192.208]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id mAKBTtrV017010 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Thu, 20 Nov 2008 11:29:58 GMT From: "David Allsopp" To: "'Stefano Zacchiroli'" , 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> In-Reply-To: <20081120104914.GA14355@usha.takhisis.invalid> Subject: RE: [Caml-list] open Module (not?) considered harmful Date: Thu, 20 Nov 2008 11:29:44 -0000 Organization: MetaStack Solutions Ltd. Message-ID: <000001c94b03$4f55d4e0$ee017ea0$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AclK/aaoGQAjbpE7QnmAv25w5XYWaAAA+Ibg Content-Language: en-gb X-Scanned-By: MIMEDefang 2.64 on 81.102.132.74 X-Cloudmark-Analysis: v=1.0 c=1 a=Oh2BfzIG4S8A:10 a=wNK47KOO6VkA:10 a=Mb5Z6DSz-nFmAeXhZBkA:9 a=IsXLtlubcevp5YNWEDgA:7 a=O7so1EAZ0EkvvZ2cnpwH9IxH1tYA:4 a=LY0hPdMaydYA:10 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 20,:98 wrote:01 wrote:01 readable:01 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 [];; 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). David