caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Boom <hendrik@topoi.pooq.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Warnings opening modules (was: why is building ocaml hard?)
Date: Fri, 15 Jul 2016 12:13:08 -0400	[thread overview]
Message-ID: <20160715161308.GB30333@topoi.pooq.com> (raw)
In-Reply-To: <002601d1de7e$9f5776d0$de066470$@metastack.com>

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

  reply	other threads:[~2016-07-15 16:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-10 11:57 David Allsopp
2016-07-10 19:45 ` Gerd Stolpmann
2016-07-13 12:08   ` David Allsopp
2016-07-13 12:20     ` Gerd Stolpmann
2016-07-13 12:30       ` David Allsopp
2016-07-14  9:03     ` Goswin von Brederlow
2016-07-15  9:52       ` David Allsopp
2016-07-15 16:13         ` Hendrik Boom [this message]
2016-07-15 16:57           ` Yotam Barnoy
2016-07-15 18:09             ` Jeremy Yallop
2016-07-15 18:26               ` Hendrik Boom
2016-07-15 18:58               ` Yotam Barnoy
2016-07-15 19:26                 ` Hezekiah M. Carty
2016-07-15 19:42                   ` Yotam Barnoy
2016-07-15 19:52                     ` Jeremy Yallop
2016-07-15 20:25                       ` Yotam Barnoy
2016-07-15 18:50             ` Alain Frisch
2016-07-15 19:44               ` Hendrik Boom
2016-07-15 17:04           ` Gerd Stolpmann
2016-07-20  7:49             ` Louis Gesbert
2016-07-16  7:40           ` Petter A. Urkedal
2016-07-16  9:58             ` vrotaru.md
2016-07-19 16:37               ` Yotam Barnoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160715161308.GB30333@topoi.pooq.com \
    --to=hendrik@topoi.pooq.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).