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: | Eijiro Sumii <eijiro_sumii@a...> |
| Subject: | Re: [Caml-list] ambitious proposal: polymorphic arithmetics |
From: "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl> | + can't be treated in the same way, because it won't distinguish | whether it's called as 1 + 1 or true + true. If it returns 2 in the | former case, it would produce a nonsensical bool value in the latter | case. | | OCaml doesn't have a mechanism for making +, - applicable to a limited | set of types and for dispatching their implementation based on the type | rather than on the physical representation. This is an excellent point. (Somebody else also pointed it out in a reply to me.) From: padiolea@irisa.fr > In the module Obj of the caml library there is a function > external is_int : t -> bool = "%obj_is_int" But it doesn't quite work for our purpose here, for example: # type t = A | B ;; type t = A | B # Obj.is_int (Obj.magic A) ;; - : bool = true Eijiro