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 VAA03974; Tue, 20 Nov 2001 21:01:02 +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 VAA03333 for caml-list@pauillac.inria.fr; Tue, 20 Nov 2001 21:01:01 +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 RAA00298 for ; Tue, 20 Nov 2001 17:48:17 +0100 (MET) Received: from sj1-3-4-9.iserver.com (sj1-3-4-9.iserver.com [128.121.214.42]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fAKGmGT18484 for ; Tue, 20 Nov 2001 17:48:16 +0100 (MET) Received: (qmail 59529 invoked by uid 16863); 20 Nov 2001 16:48:14 -0000 Received: from unknown (HELO localhost) ([unknown]) (envelope-sender ) by unknown (qmail-ldap-1.03) with SMTP for ; 20 Nov 2001 16:48:14 -0000 Date: Tue, 20 Nov 2001 16:48:14 +0000 (GMT) From: Brian Rogoff To: Shivkumar Chandrasekaran cc: caml-list@inria.fr Subject: Re: [Caml-list] functors with style? In-Reply-To: <3B7E6820-DD3A-11D5-9119-003065BDAA76@ece.ucsb.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 19 Nov 2001, Shivkumar Chandrasekaran wrote: > 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. Indeed, I find that this very issue has annoyed me for many years. When I first started playing with C++ I was involved in scientific computing and I was less interested in the OO features than I was in overloading, templates, and operator redefinition. I'd actually prefer the C++ style expansion in the case you describe above, and in many others. The other issue I have with functorial programming is the inability to have types and functor applications in a recursive relationship, but this is a well known problem and I think people at INRIA are working on it. > 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. There's also an evil fact that's unkown to many people, namely that DEC^H^H^HCompaq^H^H^H^H^H^H, ummm, HP?, has a patent which may cover some helpful techniques. DEC had implemented their own Ada 83 compiler, and, unlike C++ templates, Ada generics can be implemented by sharing as well as by "macro expansion", and some of the DEC implementors had patented a scheme which did both sharing and expansion. I'm not sure if this matters, but I can try and find the reference if anyone is really interested. -- Brian ------------------- 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