Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005625OCaml~DO NOT USE (was: OCaml general)public2012-05-29 05:272015-12-11 19:04
Assigned Togarrigue 
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version 
Summary0005625: Exception aliasing not available in signatures
DescriptionAn exception can be defined as equal to another exception:
  exception-definition ::= exception constr-name = constr
But within a .mli file, one cannot expose this equality:
  specification ::= exception constr-decl
Steps To Reproduceadd:

    exception Empty = Stack.Empty

to a .mli file
Additional InformationBatteries has use for "exception Empty = Stack.Empty" in our batStack.mli file, otherwise we'll have a BatStack.Empty and a Stack.Empty that aren't the same. We could remove the exception from the .mli file, but then it wouldn't be in the documentation as it should, and the test that (BatStack : module type of Stack) would fail, and would need... hmm, I don't think that the exception can be removed from the module type. But that's another issue.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
garrigue (manager)
2012-05-29 07:55

There is a confusion here.
An exception constructor is just a value, that you can re-export at the value level using the "exception E = <path>" construct.
There is no need to show the sharing in the interface: they are identical at the value level.
thelema (reporter)
2012-05-29 15:48

Ah, my mistake. I was testing using (==), but this is apparently a bad function to use on exceptions.

# module A = struct exception X end;;
module A : sig exception X end
# module B : sig exception X end = struct exception X = A.X end;;
module B : sig exception X end
# B.X = A.X;;
- : bool = true
# B.X == A.X;;
- : bool = false
# A.X == A.X;;
- : bool = false

Thanks for the quick clarification.
frisch (developer)
2012-06-01 05:29

A new exception value is created each time you refer to the exception constructor, so you get physically different values (and == returns false).

"=" is also not very good on exceptions, as it compares only the name of the constructors (as strings) and, if they match, the arguments (even if they have different types).

If you can, you should prefer pattern matching.

- Issue History
Date Modified Username Field Change
2012-05-29 05:27 thelema New Issue
2012-05-29 07:55 garrigue Note Added: 0007468
2012-05-29 07:55 garrigue Status new => resolved
2012-05-29 07:55 garrigue Resolution open => no change required
2012-05-29 07:55 garrigue Assigned To => garrigue
2012-05-29 15:48 thelema Note Added: 0007470
2012-06-01 05:29 frisch Note Added: 0007490
2015-12-11 19:04 xleroy Status resolved => closed
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