[TYPES] breaking abstraction with ML exceptions

Sam Lindley <[email protected]>
Newsgroups gmane.comp.science.types
Message-ID <[email protected]>
[ The Types Forum, http://lists.seas.upenn.edu/mailman/listinfo/types-list ]

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.