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 UAA14931; Mon, 19 Nov 2001 20:45:30 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA12308 for caml-list@pauillac.inria.fr; Mon, 19 Nov 2001 20:45:29 +0100 (MET) 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 TAA11867 for ; Mon, 19 Nov 2001 19:28:25 +0100 (MET) Received: from smtp2.cswv.com (smtp2.cswv.com [4.17.129.20]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAJISOb04302 for ; Mon, 19 Nov 2001 19:28:24 +0100 (MET) Received: from exchange1.cswv.com ([10.2.3.9]) by smtp2.cswv.com with Microsoft SMTPSVC(5.5.1877.197.19); Mon, 19 Nov 2001 13:28:11 -0500 Received: by exchange1.cswv.com with Internet Mail Service (5.5.2653.19) id ; Mon, 19 Nov 2001 13:32:14 -0500 Message-ID: From: "Krishnaswami, Neel" To: "'William Harold Newman'" , "'caml-list@inria.fr'" Subject: Re: [Caml-list] functors with style? Date: Mon, 19 Nov 2001 13:32:12 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk William Harold Newman [mailto:william.newman@airmail.net] wrote: > > If I did use explicit functor expressions everywhere, it'd be readable > enough: if my intent is make the things exactly parallel, then using > the explicit functor expressions everywhere would make that obvious, > so I'd be happy. But because my previous closest approach to functors > was using templates in g++, I'm predisposed to worry about the > compiler emitting multiple copies of the functor expansion if I don't > give the functor expansion a home in a particular file. Is that an > issue in Ocaml? If I understand the papers that the people at INRIA wrote, there is no such template-expansion-like problem in Ocaml. A functor is compiled to what is essentially a function that takes a record as an argument (the module it receives as an argument), and returns a record of functions and values. So code generation happens only once for each functor, and each functor application takes a very small amount of memory at link time. A lot of the issues surrounding functors become much clearer when you get an operational model for how it works: think of the ML module language as a small functional language, with functors mapping to lambdas and functor applications mapping to function applications. Then your intuition about how (for example) closures are represented can guide you towards understanding how modules and functors work. When I got this I was seriously impressed with how elegantly it all works out. (Or as we said in my native South Carolina: Them ML hackers sure are pretty smart, ain't they? :) -- Neel Krishnaswami neelk@cswcasa.com ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr