Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Map efficiency?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
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

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

module A = struct

  let f x = let module X = x in X.do_something()

In file

module B = struct

  let f x = let module X = x in X.do_something() + A.do_something()


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.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: