From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA02896; Fri, 7 Nov 2003 15:08:59 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA02655 for ; Fri, 7 Nov 2003 15:08:58 +0100 (MET) Received: from sark.cc.gatech.edu (sark.cc.gatech.edu [130.207.7.23]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hA7E8o128473 for ; Fri, 7 Nov 2003 15:08:54 +0100 (MET) Received: from gaia.cc.gatech.edu (gaia.cc.gatech.edu [130.207.3.8]) by sark.cc.gatech.edu (8.12.10/8.12.8) with ESMTP id hA7E8l6c017607; Fri, 7 Nov 2003 09:08:47 -0500 (EST) Received: (from fernando@localhost) by gaia.cc.gatech.edu (8.12.10/8.12.8) id hA7E8lw3010766; Fri, 7 Nov 2003 09:08:47 -0500 (EST) Date: Fri, 7 Nov 2003 09:08:47 -0500 From: Fernando Alegre To: "Yaron M. Minsky" Cc: Caml List Subject: Re: Why are functors better? (Re: [Caml-list] Map efficiency?) Message-ID: <20031107140847.GA8256@gaia.cc.gatech.edu> References: <20031104093905.GF24152@st> <3FA7EC77.50502@baretta.com> <16299.22375.433305.104788@gargle.gargle.HOWL> <1068205181.30150.12.camel@dragonfly.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1068205181.30150.12.camel@dragonfly.localdomain> User-Agent: Mutt/1.4.1i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alegre:01 gatech:01 functors:01 caml-list:01 yaron:01 minsky:01 functors:01 struct:01 struct:01 spaghetti:01 sig:01 nov:01 trivial:01 modules:02 modules:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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