Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001381OCamlOCaml generalpublic2002-09-10 15:372012-01-25 16:01
Reporteradministrator 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001381: open_as would be convenient
DescriptionHere's a wish list item.

I don't like to use open. If I encounter code like

   open An_excellent_module
   open A_good_module
   open A_mediocre_module
   let _ = f ()

I might have to search all three modules to discover where f is
defined. In .ml files, a simple fix is to omit the open statements
and have:

   let _ = A_good_module.f ()

That tends to get wordy, so I often do this instead:

   module G = A_good_module
   let _ = G.f ()

This is brief and unambiguous, and it works well.

In signatures, this doesn't work. I can say

   val x: A_good_module.t

but there's no easy way I know of to abbreviate it down to

   val x: G.t

Certainly saying "module G = A_good_module" in a signature doesn't
work. I've tried a number of workarounds, but none that I liked. The
one I'm using now noticeably slows down the compiler and makes
ocamlbrowser nearly useless, for instance.

Thus, I'd like to have a new type of open. The syntax in a signature
might be:

   open A_good_module as G

or perhaps

   open G = A_good_module

After you do this, the declaration:

   val x: G.t

would be exactly equivalent to having

    val x: A_good_module.t

in the signature.

If you're willing to seriously consider accepting a patch for this,
let me know and I might try to produce one. I don't want to produce a
patch without such an expression of interest because the previous two
ocaml patches I proposed (bugs 1289 and 1341) have not received a reply.
--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78

TagsNo tags attached.
Attached Files

- Relationships
related to 0001382closed First class polymorphism losing with separate compilation 

-  Notes
(0000139)
administrator (administrator)
2002-09-13 04:43

This is not an answer to your main question, but just about ocamlbrowser:

> Certainly saying "module G = A_good_module" in a signature doesn't
> work. I've tried a number of workarounds, but none that I liked. The
> one I'm using now noticeably slows down the compiler and makes
> ocamlbrowser nearly useless, for instance.

Supposing that your method is the one used in PR#1382, I would suggest you name
the file differently from the module it contains.

ConsciousImpl.ml:
module type Conscious = sig ... end
module Conscious : Conscious = struct .. end

If you use the same name, ocamlbrowser is unable to see that a reference
to Conscious inside module Conscious is about the file Conscious, because
it has already opened Conscious in the environment (needed for type
definitions...)
So you could say this is an ocamlbrowser bug, but naming two modules identically
doesn't seem to be a very good idea.

For the compiler speed, I believe I know the workaround, but must convince
Xavier first...

Cheers,

Jacques

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2012-01-25 16:01 doligez Relationship added related to 0001382


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker