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 XAA14291; Thu, 17 Oct 2002 23:37:32 +0200 (MET DST) 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 XAA15015 for ; Thu, 17 Oct 2002 23:37:31 +0200 (MET DST) Received: from boule.etirade.com (12-247-44-244.client.attbi.com [12.247.44.244]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g9HLbU523015 for ; Thu, 17 Oct 2002 23:37:30 +0200 (MET DST) Received: (qmail 27796 invoked from network); 17 Oct 2002 21:37:28 -0000 Received: from unknown (HELO batard.etirade.com) (192.168.1.34) by boule.etirade.com with SMTP; 17 Oct 2002 21:37:28 -0000 Content-Type: text/plain; charset="iso-8859-1" From: Jeffrey Palmer To: Brian Hurt , Chris Hecker Subject: Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement) Date: Thu, 17 Oct 2002 16:37:15 -0500 User-Agent: KMail/1.4.3 Cc: Ocaml Mailing List References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200210171637.15448.jeffrey.palmer@acm.org> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thursday 17 October 2002 4:19 pm, Brian Hurt wrote: > I will say- there is a way to get both the ease of development of > operator overloading *and* the performance of BLAS. Make matrices > first class types known to the compiler, like ints, floats, and > strings (vectors can be considered m-by-1 matrices). Now the > compiler knows what substitutions are legal or not- it can easily > replace a =3D b + c + d; with a =3D b; a +=3D c; a +=3D d;, or even a =3D= d; a > +=3D c; a +=3D b; if it feels like it. > There are alternatives to adding these as primitive types to the=20 language. In the case of C++, the concept of template metaprogramming=20 (basically a weakened macro system) has shown that it's possible to=20 generate numeric code on par with Fortran by rewriting expressions to=20 avoid pairwise evaluation. See: http://osl.iu.edu/~tveldhui/papers/iscope97/index.html http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html http://osl.iu.edu/~tveldhui/papers/Template-Metaprograms/meta-art.html for the background and some examples of this approach. However, the (obvious) problem with this approach, from a C++=20 perspective, is that it is not supported by the language. This stuff=20 was basically "discovered", rather than designed, and if you've ever=20 tried to use these techniques, this becomes VERY clear. The syntax is a=20 disaster. An in-language mechanism for this type of macro expansion (a=20 la lisp/scheme macros) would simplify this immensely. Is this approach implementable in ocaml? The C++ template mechanism has=20 complete access to the C++ type system, which makes it significantly=20 more useful than the standard preprocessor. I seem to remember an=20 earlier posting (today) indicating that this type information isn't=20 available in ocamlp4. Does anyone know of any strongly-typed languages where this type of=20 macro expansion/partial evaluation is available? (I seem to remember=20 GHC providing a hook mechanism for term rewriting during optimization,=20 but I don't think that's quite the same...) Cheers, =09- j (Actually, now that I think about it, I recall someone on one of the C++=20 newsgroups discussing the possibility of using a functional language=20 for the template language, since it seems like most of the interesting=20 things you can do with templates are functional in nature.) --=20 The river is moving. The blackbird must be flying. ------------------- 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