To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

From Wikipedia, the free encyclopedia

In computer science, A-normal form (abbreviated ANF, sometimes expanded as administrative normal form) is an intermediate representation of programs in functional programming language compilers. In ANF, all arguments to a function must be trivial (constants or variables). That is, evaluation of each argument must halt immediately.

ANF was introduced by Sabry and Felleisen in 1992[1] 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.[2] 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.

YouTube Encyclopedic

  • 1/3
    Views:
    95 131
    308 955
    6 850
  • Database Normalisation: First Normal Form
  • 1st, 2nd and 3rd Normal Form (Database Normalisation)
  • Normalisation - A Level Computer Science

Transcription

Grammar

Consider the pure λ-calculus with constants and let-expressions. The ANF restriction is enforced by

  1. allowing only values (variables, constants, and λ-terms), to serve as operands of function applications, and
  2. requiring that the result of a non-trivial expression (such as a function application) be immediately captured in a let-bound variable.

The following BNF grammars show how one would modify the syntax of λ-expressions to implement the constraints of ANF:

Original ANF
EXP ::= λ VAR . EXP
      | EXP EXP
      | VAR
      | CONST
      | let VAR = EXP in EXP

CONST ::= f | g | h
EXP ::= VAL 
      | let VAR = VAL in EXP
      | let VAR = VAL VAL in EXP

VAL ::= VAR
      | CONST
      | λ VAR . EXP

CONST ::= f | g | h

Variants of ANF used in compilers or in research often allow records, tuples, multiargument functions, primitive operations and conditional expressions as well.

Examples

The expression:

f(g(x),h(y))

is written in ANF as:

let v0 = g(x) in
    let v1 = h(y) in
        f(v0,v1)

By imagining the sort of assembly this function call would produce:

;; let v0 = g(x)
move x into args[0]
call g
move result into temp[0]
;; let v1 = h(y)
move y into args[0]
call h
move result into temp[1]
;; f(v0, v1)
move temp[0] into args[0]
move temp[1] into args[1]
call f

One can see the immediate similarities between ANF and the compiled form of a function; this property is a part of what makes ANF a good intermediate representation for optimisations in compilers.

See also

References

  1. ^ 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. CiteSeerX 10.1.1.22.7509. Sabry92.
  2. ^ Flanagan, Cormac; Sabry, Amr; Duba, Bruce F.; Felleisen, Matthias. "The Essence of Compiling with Continuations" (PDF). Proceedings ACM SIGPLAN 1993 Conf. on Programming Language Design and Implementation, PLDI'93. Albuquerque, NM, USA. Flanagan93. Retrieved 2012-11-16.


This page was last edited on 22 April 2024, at 00:32
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.