|Anonymous | Login | Signup for a new account||2015-04-26 19:19 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005625||OCaml||OCaml general||public||2012-05-29 05:27||2012-06-01 05:29|
|Status||resolved||Resolution||no change required|
|Target Version||Fixed in Version|
|Summary||0005625: Exception aliasing not available in signatures|
|Description||An 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 Reproduce||add:|
exception Empty = Stack.Empty
to a .mli file
|Additional Information||Batteries 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.|
|Tags||No tags attached.|
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.
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.
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.
|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|