Browse thread
[Caml-list] Understanding why Ocaml doesn't support operator overloading.
[
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: | Mike Lin <mikelin@M...> |
| Subject: | Re: [Caml-list] Understanding why Ocaml doesn't support operator overloading. |
> > No. Compiler trates polymorphic types as abstract then. It need not > know > what is the exact type, all it cares about is size of data, which in > case of OCaml on 32 bit machines is always 4 bytes. > > For example in: > ....... Fair enough. I'm curious though: Say I'm the programmer and I would like to solve the problem of combining different types of numbers with a fairly uniform syntax. I'm either going to define a union type for numbers and have all my functions pattern-match, or else I'm going to write several versions of my functions to handle different types of numbers and call different ones as appropriate. I would wish that if all my functions were built up from the primitives +, -, *, /, etc. the compiler could do this for me. The compiler may have to generate many different versions if I use them all, but otherwise I would have to write them myself! I don't think this whole thing is a good idea in general, but I don't buy this practicality/efficiency argument against it. > > Again: Haskell does it, so typing isn't real issue here. Haskell also does not have mutable data, and I think it has been well established in the literature that mutable data complicates subtyping and intersection typing. So, as others are pointing out, I definitely think typing is a real issue here. -Mike ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners