It is well known that self applicable partial evaluation can be used to generate compiler generators cogen mix mix mix where mix is the specializer partial eval uator However writing cogen by hand gives several ad vantages Contrasting to when writing a self applicable mix one is not restricted to write cogen in the same lan guage as it treats HL A handwritten cogen can be more e cient than a cogen generated by self application in particular a handwritten cogen typically performs no time consuming environment manipulations whereas one generated by self application does When working in statically typed languages with user de ned data types the self application approach requires encoding data type values Bon Lau DNBV resulting in relatively ine cient cogen generated compilers that spend much of their time on coding and decoding By writing cogen by hand the coding problem is eliminated HL BW Specializers written in continuation passing style ab breviated cps perform better than specializers written in direct style abbreviated ds Bon For example a specializer written in cps straightforwardly handles non unfoldable let expressions with static body The contribution of this paper is to combine the idea of hand writing cogen with cps based specialization We develop a handwritten cps cogen which is superior to a ds cogen for the same reason that a cps specializer is superior to a ds specializer the cps cogen can for example handle non unfoldable let expressions with static body Hand writing a cps cogen is done along the same lines as hand writing a ds cogen but some additional non standard two level expansions turn out to be needed The handwritten cps cogen presented here is e cient in that it performs continuation processing reductions of continuation applications already at compiler generation time Only some continuation processing can be done at Current postal address Computer Resources International A S Bregner dvej DK Birker d Denmark e mail use anders diku dk Funded by the National Fund for Scienti c Research Belgium This work was done during two stays at DIKU in Copenhagen DIKU and K U Leuven supported Dirk Dussart s visits to DIKU compiler generation time however so the resulting pro grams generated by cogen also contain continuations We prove our handwritten cps cogen correct with respect to a cps specializer We also give a correctness proof of a handwritten ds cogen this proof is much simpler than the cps proof but to the best of our knowledge no handwritten ds cogen has been proved correct before
[1]
Erik Sandewall,et al.
A Partial Evaluator, and its Use as a Programming Tool
,
1976,
Artif. Intell..
[2]
Anders Bondorf,et al.
Automatic Autoprojection of Higher Order Recursive Equations
,
1990,
Sci. Comput. Program..
[3]
Karel De Vlaminck,et al.
Partial Evaluation of Polymorphically Typed Functional Languages: the Representation Problem
,
1991,
JTASPEFT/WSA.
[4]
Anders Bondorf,et al.
Improving binding times without explicit CPS-conversion
,
1992,
LFP '92.
[5]
Neil D. Jones,et al.
A partial evaluator for the untyped lambda-calculus
,
1991,
Journal of Functional Programming.
[6]
Carsten Kehler Holst.
Syntactic currying: yet another approach to partial evaluation
,
1989
.