[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 1999-10-14 (12:59) |
From: | Manuel Fahndrich <maf@m...> |
Subject: | Rebinding exception declarations |
While we are at wishing for new features in OCaml, let me add a minor feature to the list: Rebinding of exception declarations. Currently, in OCAML I cannot do the following: module A = struct exception E end module B = struct exception E = exception A.E end In order to have an exception declaration in a module, it must syntactically appear there. That prevents me from repackaging my modules in a different way for the programmer interface. The only way around it is currently to define a brand new exception and wrap all interface functions with a handler that translates A.E into B.E. One argument against providing such exception rebinding is that it introduces aliasing between exception constructors. However, OCAML already has that problem now through functors. Consider: module type Argsig = sig module X : sig exception E end module Y : sig exception E end end module F = functor(Arg : Argsig) -> struct try ... with Arg.X.E -> ... | Arg.Y.E -> ... end module A = struct exception E end module Z = F(struct module X = A module Y = A end) Within Z, exceptions Arg.X.E and Arg.Y.E are aliased. -Manuel P.S. Exception rebinding is standard in SML.