You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1381 Reporter: administrator Status: closed (set by @damiendoligez on 2016-12-02T14:14:44Z) Resolution: fixed Priority: normal Severity: feature Fixed in version: 4.02.0 Category: ~DO NOT USE (was: OCaml general) Related to:#3653
Bug description
Here'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
The text was updated successfully, but these errors were encountered:
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 #3653, 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...
Original bug ID: 1381
Reporter: administrator
Status: closed (set by @damiendoligez on 2016-12-02T14:14:44Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.02.0
Category: ~DO NOT USE (was: OCaml general)
Related to: #3653
Bug description
Here'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
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
The text was updated successfully, but these errors were encountered: