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=1.8 required=5.0 tests=AWL,DNS_FROM_SECURITYSAGE, SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id ECB06BBAF for ; Thu, 20 Nov 2008 12:41:04 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvECAJvbJElQRFuwgWdsb2JhbACTWwEBFiK+CIJ8 X-IronPort-AV: E=Sophos;i="4.33,639,1220220000"; d="scan'208";a="31642209" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 20 Nov 2008 12:41:04 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1L37uB-0006wa-I5; Thu, 20 Nov 2008 11:41:03 +0000 Date: Thu, 20 Nov 2008 11:41:03 +0000 To: Stefano Zacchiroli Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] open Module (not?) considered harmful Message-ID: <20081120114103.GA26521@annexia.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081120104914.GA14355@usha.takhisis.invalid> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; 0100,:01 zacchiroli:01 printf:01 tuareg:01 ocaml:01 syntax:01 foo:01 runtime:01 cpan:01 20,:98 20,:98 wrote:01 wrote:01 caml-list:01 functions:01 On Thu, Nov 20, 2008 at 11:49:14AM +0100, 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. > > Problem 1) once you open you loose the information where an identifier > comes from. True, but it is a tool deficiency, not an intrinsic > deficiency. > AFAIU Ocamlwizard addresses that [1]. Well, it is a tool deficiency, but the fact is that it's a deficiency we have, and until someone writes the tuareg extension for ocamlwizard, we'll continue to have this deficiency. (Better not forget vi users, ocamde users, Eclipse, etc.) 'Course, that fixes the editor part, but there's still all the other places where OCaml code can be displayed - eg. on web pages, in version control systems, in books, .. - so better extend ocamlwizard to those areas too. [...] > 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. Again, Perl gets this mostly right, in that the module developer can define "modes of use" of the module. In Perl something like: use CGI qw(:standard); causes all the "standard" symbols to be imported (as defined by the module author). Or you can import just the symbols you want. As befits a dynamic language, the implementation is completely flexible -- at runtime the module sees the literal string parameter and can decide to export any combination of symbols it likes based on the string parameter. An example of how flexible and idiomatic that can be is shown here: http://search.cpan.org/dist/CGI.pm/CGI.pm#SPECIAL_FORMS_FOR_IMPORTING_HTML-TAG_FUNCTIONS Rich. -- Richard Jones Red Hat