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: | Gordon Henriksen <gordonhenriksen@m...> |
| Subject: | Re: [Caml-list] "OCaml gives you only monomorphic methods in classes." |
Oh, were you proposing a language feature? In that case, consider: let bar x = foo x How to compile that? - Gordon On Dec 28, 2007, at 17:27, Jon Harrop <jon@ffconsultancy.com> wrote: > 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 > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs