[TYPES] breaking abstraction with ML exceptions
Sam Lindley
Sam.Lindley at ed.ac.uk
Wed Mar 28 05:49:46 EDT 2018
The following SML program
exception C;
structure M :> sig exception A end =
struct
exception A = C
end;
(raise M.A) handle C => 42
returns the value 42 (according to SML/NJ and, I believe, the 1997 definition of
Standard ML).
The signature ascription appears to assert that exception A is abstract in M,
and yet we are able to raise the exception M.A and catch it as C outside the
scope of M. It makes no difference whether the signature ascription is
transparent or opaque. The equivalent OCaml program yields the same result.
Does this kind of code occur in practice?
Sam
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the Types-list
mailing list