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 JAA22232; Tue, 20 Nov 2001 09:27:40 +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 JAA22289 for caml-list@pauillac.inria.fr; Tue, 20 Nov 2001 09:27:39 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA16406 for ; Mon, 19 Nov 2001 23:10:28 +0100 (MET) Received: from hub.ucsb.edu (hub.ucsb.edu [128.111.24.40]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fAJMAQ128212 for ; Mon, 19 Nov 2001 23:10:27 +0100 (MET) Received: from smeagol.ece.ucsb.edu ([128.111.56.20]) by hub.ucsb.edu with esmtp id 165wcT-000D91-00 for caml-list@inria.fr; Mon, 19 Nov 2001 14:10:25 -0800 Date: Mon, 19 Nov 2001 14:10:25 -0800 Subject: Re: [Caml-list] functors with style? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v475) From: Shivkumar Chandrasekaran To: caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <3B7E6820-DD3A-11D5-9119-003065BDAA76@ece.ucsb.edu> X-Mailer: Apple Mail (2.475) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Monday, November 19, 2001, at 10:32 AM, Krishnaswami, Neel wrote: > > 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. > Which of course is a problem at the "small-scale". For example I would like to develop a functor that is generic over the representation of reals (float32_elt, float64_elt, fixed_point, etc.). But now if I instantiate it for float64_elt and do arithmetic over float64_elt even simple operations will be looked-up at run-time leading to a terrible performance loss. Ideally I would prefer it if the compiler allowed the programmer to decide which functor applications lead to compile-time code generation and which are through dictionary-passing. For example, in Clean (which has type classes not functors of course), instants of basic types be prevented from using dictionary passing. Not sure what happens in haskell though... --shiv-- ------------------- 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