Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006363OCamlOCaml generalpublic2014-04-05 05:542014-04-06 11:15
Reportermkehrt 
Assigned Tolefessan 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006363: Local module opens
DescriptionI've been writing a lot of Scala recently, and on returning to OCaml, there is one feature I miss a lot. This is the ability to locally open a module inside a non-toplevel scope. In OCaml this would manifest as an "open ... in" binding used as follows:

let f x =
  ...bindings...
  open M in
  ...more bindings and expressions...

This would be particularly useful when using modules to manage the namespaces of record labels, as one could open the module containing the record labels in a function dealing with that record but allow the labels to be namespaced elsewhere. This could avoid the variable.ModuleName.fieldName syntax, which is fairly cumbersome.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0011229)
mkehrt (reporter)
2014-04-05 06:01

Similarly, local module bindings

let f x =
  module M = ModuleName in
  ...

I realize these are fairly large changes to the language, but I think they would be useful in a future release.
(0011230)
garrigue (manager)
2014-04-05 07:34

Both of these features are available.
They are described in the language extension part of the manual.
The syntax is respectively
  let open M in
and
  let module M = ... in
(0011232)
lefessan (developer)
2014-04-06 11:15

There is also M.{ x = .. } and M.( { x = } ) that can be used to open a module within an expression/record.

- Issue History
Date Modified Username Field Change
2014-04-05 05:54 mkehrt New Issue
2014-04-05 06:01 mkehrt Note Added: 0011229
2014-04-05 07:34 garrigue Note Added: 0011230
2014-04-05 07:34 garrigue Status new => closed
2014-04-05 07:34 garrigue Assigned To => garrigue
2014-04-05 07:34 garrigue Resolution open => no change required
2014-04-06 11:15 lefessan Assigned To garrigue =>
2014-04-06 11:15 lefessan Note Added: 0011232
2014-04-06 11:15 lefessan Status closed => feedback
2014-04-06 11:15 lefessan Resolution no change required => reopened
2014-04-06 11:15 lefessan Status feedback => closed
2014-04-06 11:15 lefessan Assigned To => lefessan
2014-04-06 11:15 lefessan Resolution reopened => no change required


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker