Browse thread
ambitious proposal: polymorphic arithmetics
[
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: | -- (:) |
| From: | William Lovas <wlovas@s...> |
| Subject: | Re: [Caml-list] ambitious proposal: polymorphic arithmetics |
On Wed, Apr 06, 2005 at 03:33:56PM -0400, Eijiro Sumii wrote:
> From: "William Lovas" <wlovas@stwing.upenn.edu>
> > (This argument breaks down in
> > the face of code which relies on abstract types to enforce modularity -- in
> > such cases, incomparability can become "the rule" rather than the
> > exception, putting =, <, etc. on the same footing as +, -, etc.)
>
> Yes, polymorphic comparison already breaks type abstraction.
I did not realize this! Can somebody explain the following interactions?
# let r = Ratio.ratio_of_int 5;;
val r : Ratio.ratio = <abstr>
# r = r;;
Exception: Invalid_argument "equal: abstract value".
# module M : sig type t;; val of_int : int -> t end =
struct type t = int;; let of_int x = x end;;
module M : sig type t val of_int : int -> t end
# let t = M.of_int 5;;
val t : M.t = <abstr>
# t = t;;
- : bool = true
I thought that perhaps all comparisons of abstract values resulted in a
runtime error, but evidently i was mistaken :/ What's the secret to making
a type "really" abstract?
William