> He should have used functor a little bit more > > module type E = > sig > type t > val of_int: int -> t > val add: t -> t -> t > end > ;; > > module Add3 (Elem: E) = > struct > type t = E.t > > let n3 = > E.of_int 3 > > let add3 z = > E.add z n3 > end > ;; > > module Add3Nativeint = Add3(Nativeint) > ;; > > module Add3Int64 = Add3(Int64) > ;; > > module Add3Int32 = Add3(Int32) > ;;
I used C# for a while and this example reminds me generics in this language. But generics are more laconic: you have to only declare a name of generic type and then to indicate a type of treating object like this: List<string>; or List<int32>; Ideally I would imagine the solution in OCAML somehow wihout this declaring several similar functions where types of the argument are "encoded" in their names. Is it possible to declare functions with same names but with a different type of the argument, just as it's realized in C++? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ocaml-developer" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ocaml-developer?hl=en For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html -~----------~----~----~----~------~----~------~--~---
