
On Tue, 10 Oct 2006, Simon Peyton-Jones wrote:
That's precisely what GHC does. My explanation before was too brief, sorry. The algorithm is described in "Secrets of the GHC inliner" http://research.microsoft.com/%7Esimonpj/Papers/inlining/index.htm
But it still only makes a specialised copy if the function is "small enough". Obviously a great big function with a tiny specialisation opportunity would be a poor candidate.
Do you mean if the resulting function if ``small enough'', or the original function is small enough? Anyhow I will look at the paper.
| I must say I'm extremely disappointed with this. I believe I was taught | in my undergraduate CS program (but perhaps I wasn't) that one ought not | to make these sorts of trivial hand optimisations, because compilers are | smart enough to figure out these sorts of things by themselves, and they | know more about that target platform that you do. In particular the | propaganda about side-effect-free functional languages was a promise that | they would use the strong types and side-effect-freeness to do all sorts | of wonderful optimisations.
Well I think if you use -ddump-simpl you'll see a program that often looks pretty different to the one you wrote. I often have difficulty figuring out just how GHC managed to transform the source program into the optimised one.
I should metion that I feel that GHC does do a great optimisation job considering. It manages to transform a language, largely based on abstract mathematics, into something that a Von Neumann can run in practise. This is, of course, and amasing feat. I am just going to have to learn that the comipler won't do optimisations that I think it ought to figure out. So I will either have to start writing hand tunned non-portable, potentially unsafe code, or figure out how to extend GHC optimizer. I prefer the later. -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''