|This article relies too much on references to primary sources. (October 2011)|
In computer science, A-normal form (abbreviated ANF) is an intermediate representation of programs in functional compilers introduced by Sabry and Felleisen in 1992 as a simpler alternative to continuation-passing style (CPS). Some of the advantages of using CPS as an intermediate representation are that optimizations are easier to perform on programs in CPS than in the source language, and that it is also easier for compilers to generate machine code for programs in CPS. Flanagan et al. showed how compilers could use ANF to achieve those same benefits with one source-level transformation; in contrast, for realistic compilers the CPS transformation typically involves additional phases, for example, to simplify CPS terms.
- allowing only constants, λ-terms, and variables, to serve as arguments of function applications, and
- requiring that the result of a non-trivial expression be captured by a let-bound variable or returned from a function.
EXP ::= VAL VAL | let VAR = EXP in EXP VAL ::= λ VAR . EXP | VAR
Variants of ANF used in compilers or in research often allow constants, records, tuples, multiargument functions, primitive operations and conditional expressions as well.
is written in ANF as:
let v0 = g(x) in let v1 = h(y) in f(v0,v1)
- Sabry, Amr; Felleisen, Matthias. "Reasoning about Programs in Continuation-Passing Style". Proceedings of the 1992 ACM Conference on LISP and Functional Programming, LFP'92. San Francisco, CA, USA. Sabry92. Retrieved 2012-11-16.
- Flanagan, Cormac; Sabry, Amr; Duba, Bruce F.; Felleisen, Matthias. "The Essence of Compiling with Continuations". Proceedings ACM SIGPLAN 1993 Conf. on Programming Language Design and Implementation, PLDI'93. Albuquerque, NM, USA. Flanagan93. Retrieved 2012-11-16.
|This programming language–related article is a stub. You can help Wikipedia by expanding it.|