FORTRAN (was Re: indentation)

Andrew M. Kuchling akuchlin at mems-exchange.org
Thu Dec 9 17:34:18 EST 1999


Phil Austin <phil at geog.ubc.ca> writes:
>    MHz pentium.  Once C++ compilers mature to the point where
>    expression templates impose as little compile-time overhead as
>    Fortran intrinsic arrays, it might be time for scientists to reexamine
>    their language choices.

A while back David Ascher pointed out "Techniques for Scientific C++",
by Todd Veldhuizen , the author of Blitz++.  It's a great paper for
language geeks, even if you're not interested in numerics:

http://www.extreme.indiana.edu/~tveldhui/papers/techniques/techniques.html

An excerpt from section 11 on template metaprograms:

	Unruh's program tricks the compiler into printing out a list of prime
	numbers at compile time. It turns out that C++ templates are an
	interpreted programming ``language'' all on their own. There are
	analogues for the common control flow structures: if/else/else if,
	for, do..while, switch, and subroutine calls.
	...
	Are there any limits to what computations one can do with
	templates at compile time? In theory, no-- it's possible to
	implement a Turing machine using template instantiation.

	The implications are that (1) any arbitrary computation can be
	carried out by a C++ compiler; (2) whether a C++ compiler will
	ever halt when processing a given program is undecidable.

The idea that C++ compilers are Turing complete blew me away.  (Hours
of fun ... if you're Tim Peters.)  In the paper Veldhuizen shows how
to use this more practically, to generate unrolled code for things
like FFTs, a complex optimization that no compiler is going to do for
you.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Years later I was regaining consciousness in America, which is no mean feat.
    -- Waking from memories of a sister, in EGYPT #1




More information about the Python-list mailing list