Okay, you have my attention... let's see that isomorphism in practice. I have seen my own measurements, and invariably they produce code that is 30% slower for CPS form than direct form. Perhaps the compilers producing the actual native code have been tuned to look for common human idioms and not CPS traits?
Dr. David McClain Sr. VP, Embedded Systems Asyrmatos Inc. Boston & Tucson phone: 520-529-2437 cell: 520-390-3995 web: www.asyrmatos.com e-mail: dbm@asyrmatos.com
On May 22, 2009, at 12:38, Taylor R Campbell wrote:
Date: Fri, 22 May 2009 12:18:49 -0700 From: "D.McClain" dbm@asyrmatos.com
Very interesting... I would like to see your claims backed up by actual measurements.
How about an isomorphism between the set of direct-style Scheme programs and (a subset of) the set of CPS Scheme programs? Then if you give me a compiler C, I can construct a compiler C' that uses a CPS intermediate representation and such that C(P) = C'(P) for any program P. No measurement is necessary to observe that the code generated by C and C' is identical.
Put another way, turning a program into CPS doesn't add to or remove from the information in a program. So it doesn't make a compiler any more or less able to make assumptions about a program that enable it to generate better or worse code. All it changes is how convenient it is to write the compiler. It's just a way to lay out some data structures in the compiler. If someone told you that a compiler turned programs into an XML-based intermediate representation, would you believe that person if he claimed that the use of XML caused the compiler to generate bad code? (It might be indicative of incompetent software engineering on the part of the compiler's writers, but that's a different issue.)