Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005625OCamlOCaml generalpublic2012-05-29 05:272012-06-01 05:29
Reporterthelema 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionno 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
(0007468)
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.
(0007470)
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.
(0007490)
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker