Browse thread
"OCaml gives you only monomorphic methods in classes."
[
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: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] "OCaml gives you only monomorphic methods in classes." |
On Friday 28 December 2007 23:55:32 Gordon Henriksen wrote: > Jon, consider the case of Java or C++ method (and function) > overloading. This form of static dispatch is quite distinct from > virtual method dispatch, and is indeed at odds with type inference. I see. Still, the solution seems easy enough. Just treat the overloaded types as part of the function name: foo(int n) foo(float x) foo(string s) becomes: foo_int n foo_float x foo_string s When you come across: foo(a) you look up the statically inferred type of "a" and just bail if it fails to match any of the overloads. Generics are left alone: foo<T>(T x) becomes: foo (x : 'T) Would that work? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e