Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006363OCaml~DO NOT USE (was: OCaml general)public2014-04-05 05:542014-04-06 11:15
Assigned Tolefessan 
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 =
  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
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.
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
  let module M = ... in
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
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker