Browse thread
[Caml-list] Map efficiency?
[
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: | 2003-11-07 (14:08) |
From: | Fernando Alegre <fernando@c...> |
Subject: | Re: Why are functors better? (Re: [Caml-list] Map efficiency?) |
On Fri, Nov 07, 2003 at 06:39:41AM -0500, Yaron M. Minsky wrote: > Functors would be a lot more useful if they could be used as a > large-scale structural tool. Sadly, the current implementation makes > this quite difficult, since there's no good way of parameterizing > multiple modules at once (as noted in a previous thread. See This seems to be related to the fact that modules are not first class objects. If they were, you could easily parametrize across modules: In file x.ml: module type SIGX = sig ... end type x_module = SIGX module X = struct ... end let x = module (X:SIGX) (* type of x is x_module *) In file a.ml: module A = struct let f x = let module X = x in X.do_something() In file b.ml: module B = struct let f x = let module X = x in X.do_something() + A.do_something() end This code, of course, cannot be compiled. However, the corresponding version with classes is trivial to do. This fact seems to be one of the strong reasons why people prefer them over modules, despite the tendency of classes to become long spaghetti. Fernando ------------------- 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