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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 5ECCD7EF5E for ; Fri, 15 Jul 2016 18:58:12 +0200 (CEST) IronPort-PHdr: 9a23:wxedRR3fkWBHlrt+smDT+DRfVm0co7zxezQtwd8ZsegfLvad9pjvdHbS+e9qxAeQG96Ks7QY16GP6/mocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+kQsiO04/uj7n60qaQSj0AvCC6b7J2IUf+hiTqne5Sv7FfLL0swADCuHpCdrce72ppIVWOg0S0vZ/or9ZLuh5dsPM59sNGTb6yP+FhFeQZXwIdLnst6cb3mR7GRAqJrjtAAyRF2iZPVijI6h3gX5S5mCz9s6Ip2CScMdf3TpgoXiyl7uFzTxjxziwAMmhq3nvQj5lBi75SpVqLrgZ5xJ+cNJCSKPN7dKrHe9QLbWVEV8dVESdGB9XvPMM0E+MdMLMA/MHGrFwUoE77WFCh Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=yotambarnoy@gmail.com; spf=Pass smtp.mailfrom=yotambarnoy@gmail.com; spf=None smtp.helo=postmaster@mail-yw0-f172.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yotambarnoy@gmail.com) identity=pra; client-ip=209.85.161.172; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yotambarnoy@gmail.com designates 209.85.161.172 as permitted sender) identity=mailfrom; client-ip=209.85.161.172; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-yw0-f172.google.com) identity=helo; client-ip=209.85.161.172; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="postmaster@mail-yw0-f172.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0C0AAC2FYlXf6yhVdFchBR8Bqc1hX+LOoF7IoV4AoEoBzoSAQEBAQEBAQERAQEJCwsJHzGCMgQBEoIUAQUSER0BGxILAQMMBgULDQICCR0CAiIBEQEFAQoSBhMSEIdzAQMXDqNRgTE+MYs7gWqCWgWEbAoZJwMKUoNIAQEBAQEFAQEBAQEaAgYQcYUphE2EHYMkgloFhlUMgUeFYIE0iWWGE4hIgWtOhzqFQo5cEh6BDyUDgguCMCAyhRCBQwEBAQ X-IPAS-Result: A0C0AAC2FYlXf6yhVdFchBR8Bqc1hX+LOoF7IoV4AoEoBzoSAQEBAQEBAQERAQEJCwsJHzGCMgQBEoIUAQUSER0BGxILAQMMBgULDQICCR0CAiIBEQEFAQoSBhMSEIdzAQMXDqNRgTE+MYs7gWqCWgWEbAoZJwMKUoNIAQEBAQEFAQEBAQEaAgYQcYUphE2EHYMkgloFhlUMgUeFYIE0iWWGE4hIgWtOhzqFQo5cEh6BDyUDgguCMCAyhRCBQwEBAQ X-IronPort-AV: E=Sophos;i="5.28,368,1464645600"; d="scan'208";a="226823552" Received: from mail-yw0-f172.google.com ([209.85.161.172]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 15 Jul 2016 18:58:11 +0200 Received: by mail-yw0-f172.google.com with SMTP id w127so107921533ywf.3 for ; Fri, 15 Jul 2016 09:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cjpa8HuyQ84ZdFmn72Ctd7A45u+KOowY1Kp9E4+DfoU=; b=D7POk5C7pcOqzTJWZde+XSMJTFvLYGATrJX9qkjRO+0pNC8dTF8mHQvoulke2kLdL7 35V0yqrplk2j2fnFMEPQy1ba9qVAafCck4k9MGb04ZK/AtGtUGyoao8HmEfkAsfj6I3R yEpLUfHU23wgh6jDb1Fs0lJcMQPSqXmZ8HqZtqUlwv1fZSWzgCjmc8spHLanrI0gZ1Yr Aaqq6cR2SpliglH5sFutzvMrQy2HG/iozNurkhIihfN1pvPmR93DxVa9gM7ksIB6whLf XpFDEukrF+D39MNNPffbVPMdGhhAXIXpwU4Wo/YEtXMFkf1jmxTlLei3Mb8Y6TrZ7qcr QmrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cjpa8HuyQ84ZdFmn72Ctd7A45u+KOowY1Kp9E4+DfoU=; b=TrmeRAKeP0Y4XdyEum64P4Lrh6bzg8OFVP3z+paEyKI23iu4olnbH0ZZKGSaIkFbWm 2Ta3YbTGNNwo8qi/uT2GQRhZnoZHl/2MuUfQqCdNamiNbSpg28xkKk86nBbS+OO9vDkz jSYH2/GiTzGPF9EXSWt0ZZ1unnM8l8JtL1JShaGcugGqDqUcOTUMxrLlPf9sSgwab0tP cNvm+PT9KpznHVIcm0gICqNARmvzQiz3UBQC2liGxqV22RhGjayz575o6HTa28s+EjLF iRWQkPokAX0ZNlWQNhf39KqARrT9ePY2UemvzMHNwCSMoUXKE2fBV6rpaqRA98UWXc50 hnuQ== X-Gm-Message-State: ALyK8tIvK4hHgnMp4kk/MSfu4fHeAh1JTwyVd6MHYCquyfID/t0pY+C0OnLWtsk90oaWdCR5M5RvBwzscNAxAA== X-Received: by 10.37.49.66 with SMTP id x63mr14144739ybx.49.1468601890386; Fri, 15 Jul 2016 09:58:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.115.66 with HTTP; Fri, 15 Jul 2016 09:57:50 -0700 (PDT) In-Reply-To: <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> <20160715161308.GB30333@topoi.pooq.com> From: Yotam Barnoy Date: Fri, 15 Jul 2016 12:57:50 -0400 Message-ID: To: Hendrik Boom Cc: Ocaml Mailing List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Warnings opening modules (was: why is building ocaml hard?) The problem seems to stem from the fact that the same open statements which we use to import code (and which are available in every language) are also used as part of OCaml's super-flexible module system. This makes it hard to come up with easy, simple shortcuts for functionality available in other languages, because it needs to fit in the far more complex general module language. In haskell, I can just say 'import A (foo, bar, baz, t)' to limit exactly what I want to import. This is because haskell has a half-baked module system that isn't nearly as powerful as OCaml's, which allows it to create syntax that doesn't need to go anywhere but at the toplevel. We need this functionality in OCaml, but the closest thing is to say 'include struct let foo = A.foo let bar = A.bar let baz = A.baz type t = A.t end' I'm not sure if there's a performance cost to doing things this way, but it's also incredibly verbose and therefore nearly unusable in the general case simply because it needs to fit into the general module language. Additionally, haskell handles module hierarchies gracefully (tying them to the OS filesystem), while OCaml is stuck with a flat hierarchy, needing modular tricks to get the same hierarchies that other languages have naturally (via specialized syntax). The generality of OCaml's module language is killing its usability for the most common cases. On Fri, Jul 15, 2016 at 12:13 PM, Hendrik Boom wrote: > 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 > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs