Automatic Staging via Partial Evaluation Techniques
Partial evaluation and staging are two of the well-known symbolicmanipulation techniques of programs which generate efficientspecialized code. On one hand, partial evaluation provides us with anautomatic means to separate a program into two (or more) stages butits behavior is perceived as hard to control. On the other hand,staging (or staged calculus) requires us to manually separate aprogram but with full control over its behavior. In the previouswork, the first author introduced a framework to relate the twotechniques, giving a unified view to the two techniques. In thispaper, we extend the framework to handle the cross-stage persistence(CSP) and show that the 2-level staging annotation obtained by theautomatic separation is the best staging annotation in a system whereCSP is allowed for base-type values only. In the presence of CSP forhigher-type values, on the other hand, there is no single annotationthat is better than all the other annotations.