From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id D0F4C7EF5E for ; Fri, 15 Jul 2016 18:13:13 +0200 (CEST) IronPort-PHdr: 9a23:oHFELRHN8qJlvouOA2b0751GYnF86YWxBRYc798ds5kLTJ75pM+wAkXT6L1XgUPTWs2DsrQf2rKQ7/yrCT1IyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWD14Lri6viqtX6WEZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu5blitCLFOXmAvgtI/rpMYwu3cYh/V0/MdFVeD+fr8kZb1eFjUvdW4vt+PxshyWbQaJ6mEdUS08lR1NS1zF4Rf2RJbymjf9ru18njGdOtSwRrcxD2fxp5x3QQPl3X9UfwUy93va35R9 Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=hendrik@topoi.pooq.com; spf=None smtp.mailfrom=hendrik@topoi.pooq.com; spf=None smtp.helo=postmaster@april.topoi.pooq.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of hendrik@topoi.pooq.com) identity=pra; client-ip=69.165.131.134; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="hendrik@topoi.pooq.com"; x-sender="hendrik@topoi.pooq.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of hendrik@topoi.pooq.com) identity=mailfrom; client-ip=69.165.131.134; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="hendrik@topoi.pooq.com"; x-sender="hendrik@topoi.pooq.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@april.topoi.pooq.com) identity=helo; client-ip=69.165.131.134; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="hendrik@topoi.pooq.com"; x-sender="postmaster@april.topoi.pooq.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AqBgB0ColX/4aDpUVchBRLMYJ2tXyBexqGAAKBaRIBAQEBAQEBAWQngjIVghYBBTpPCxgJJQ8FGIh0wAIBAQgCJYp3hQyCYIIvBYgohWCBNIllhhOIPgpngQROhzqFQpAbJQ0igV+CMCAyhlMBAQE X-IPAS-Result: A0AqBgB0ColX/4aDpUVchBRLMYJ2tXyBexqGAAKBaRIBAQEBAQEBAWQngjIVghYBBTpPCxgJJQ8FGIh0wAIBAQgCJYp3hQyCYIIvBYgohWCBNIllhhOIPgpngQROhzqFQpAbJQ0igV+CMCAyhlMBAQE X-IronPort-AV: E=Sophos;i="5.28,368,1464645600"; d="scan'208";a="184930467" Received: from topoi.pooq.com (HELO april.topoi.pooq.com) ([69.165.131.134]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Jul 2016 18:13:11 +0200 Received: by april.topoi.pooq.com (Postfix, from userid 1001) id 7B4C7C2274; Fri, 15 Jul 2016 12:13:08 -0400 (EDT) Date: Fri, 15 Jul 2016 12:13:08 -0400 From: Hendrik Boom To: caml-list@inria.fr Message-ID: <20160715161308.GB30333@topoi.pooq.com> References: <001701d1daa2$30f7ac30$92e70490$@metastack.com> <1468179914.25014.89.camel@e130.lan.sumadev.de> <20160714090300.GB21053@frosties> <002601d1de7e$9f5776d0$de066470$@metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <002601d1de7e$9f5776d0$de066470$@metastack.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [Caml-list] Warnings opening modules (was: why is building ocaml hard?) On Fri, Jul 15, 2016 at 10:52:38AM +0100, David Allsopp wrote: > Goswin von Brederlow wrote: > > I don't follow what you mean - what I propose changing is that [open Util] > would cause a warning and eventually, in some future version of OCaml, be > rejected by the compiler. The problem it would solve is that > ocamldep/whatever knows that open Foo always refers to a toplevel (or fully > qualified) module path. > > > A (for me) more common code would be: > > > > open ReallyCoolLibraryPack > > (* myriad more open statements *) > > > > Util.foo bla baz > > module Bla = Util.MAKE(M : FOOABLE) > > > > You still get the same dependency on ReallyCoolLibraryPack.Util, > > ReallyCoolLibraryPack.Util.MAKE, ReallyCoolLibraryPack.FOOABLE, ... > > without successive opens. > > Indeed, that's my preference, although I'm stupidly picky and actually > prefer to write: > > module Util = ReallyCoolLibraryPack.Util > > but that comes under my list of "strange habits which normal people don't > agree with" :o) I'm allergic to anything which involves a wildcard ([open > ReallyCoolLibraryPack] being rather too like writing [import > ReallyCoolLibraryPack.*;]) And that's a real problem -- that fact that openning a module can fill the namespace with lots of stray identifiers, which the user does not control. It may reduce the amount of code you have to write. But it makes the code unstable in the long run, and it makes it hard to read. The naive reader will encounter identifiers and have no idea where to look for their definitions. It's not just a problem with modules that define modules. It'a a problem with modules that define anything. To alleviate this, either specify explicitly what names you are accepting definitions of when you open a module, or, after you open a module, mention the module name very time you use one if its defined names, as, Module.name instead of just name. And make the compiler check this. Withiut a constraint like this, I find much OCaml code incomprehensible. Or is there some kind of code browsing tool that explicates all this? -- hendrik