caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: bpr@best.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] two unrelated questions
Date: Tue, 01 May 2001 10:31:00 +0900	[thread overview]
Message-ID: <20010501103100X.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <Pine.BSF.4.21.0104291513410.473-100000@shell5.ba.best.com>

From: Brian Rogoff <bpr@best.com>

> I think the real beauty of this local module feature is that it allows
> things like  a local open, which may make open more palatable to
> open-phobes.
> 
> though I take it that these kinds of tricks weren't the original goal of
> the feature. Still, the syntax is light so these are very painless
> workarounds even without the P4 prettification. 

Indeed, I think they were not the original goal.
As I heard it from Xavier, this was mostly intended to allow local
instances of functors.

Particularly, local exception definitions are one of the rare features
present in SML and absent in Caml, and that some SML developpers think
that Caml is right about :-)
That is, defining local exceptions (and local types also) is a very
fine way to shoot oneself in the foot. You end up having plenty of
exceptions (or types) with the same name (impossible to distinguish at
toplevel), but incompatible. For types, this is still ok since the
type checker does not allow it to escape its scope; which can give you
funny errors:

  # let module M = struct type t = A | B end in M.A;;
  This `let module' expression has type M.t
  In this type, the locally bound module name M escapes its scope

For exceptions, logically a locally defined exception escaping its
scope should be a fatal error, but this is not the case (cannot be
really enforced). So you can end up at toplevel getting an exception
of an unknown name, impossible to catch. (This is the problem SMLers
cite most often).

On the other hand, I perfectly agree with you that opening a module
locally is something you want to do often, and causes no safety
problem at all.
That's one of the reasons I think mixing it with let module is not
good: the let module feature is theoretically subtle, and should be
used with care, while a let open construct does nothing (just changes
the static scope), and does not require the same caution.

Cheers,

Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-05-01  1:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-25 21:08 Chris Hecker
2001-04-26  0:38 ` Patrick M Doane
2001-04-26  6:04   ` Judicaël Courant
2001-04-26 12:06     ` John Max Skaller
2001-04-27  9:12       ` Anton Moscal
2001-04-29 22:24         ` Brian Rogoff
2001-04-30 18:57           ` Fergus Henderson
2001-05-01  1:31           ` Jacques Garrigue [this message]
2001-05-01 12:45             ` [Caml-list] " Ken Friis Larsen
2001-04-27 15:09       ` [Caml-list] " Brian Rogoff
2001-04-27 17:49         ` John Max Skaller
2001-04-26  8:22   ` Andreas Rossberg
2001-04-26  1:13 ` Jacques Garrigue
2001-04-26 13:47 ` Xavier Leroy
2001-04-26 22:34   ` Chris Hecker
2001-04-26 16:57 ` Mark Seaborn
2001-04-26 22:20   ` John Max Skaller
2001-05-01 21:08     ` Brian Rogoff
2001-05-01 23:30       ` John Max Skaller
2001-05-02  0:03       ` John Max Skaller
2001-05-01 17:25 Dave Berry

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=20010501103100X.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=bpr@best.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).