Constructed product result analysis
Encyclopedia
In the field of compiler
implementation in computer science
, constructed product result analysis (or CPR analysis) is a static analysis
that determines which functions in a given program can return multiple results in an efficient manner. Typically, this means returning multiple results in a register
(as opposed to returning a pointer to an tuple
allocated on the heap whose components are the function's multiple return values.)
CPR analysis was introduced in the context of compiling Haskell
(a lazy
functional language
) and is implemented in the Glasgow Haskell Compiler
. It may be applicable to other programming languages as well.
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
implementation in computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...
, constructed product result analysis (or CPR analysis) is a static analysis
Static code analysis
Static program analysis is the analysis of computer software that is performed without actually executing programs built from that software In most cases the analysis is performed on some version of the source code and in the other cases some form of the object code...
that determines which functions in a given program can return multiple results in an efficient manner. Typically, this means returning multiple results in a register
Processor register
In computer architecture, a processor register is a small amount of storage available as part of a CPU or other digital processor. Such registers are addressed by mechanisms other than main memory and can be accessed more quickly...
(as opposed to returning a pointer to an tuple
Tuple
In mathematics and computer science, a tuple is an ordered list of elements. In set theory, an n-tuple is a sequence of n elements, where n is a positive integer. There is also one 0-tuple, an empty sequence. An n-tuple is defined inductively using the construction of an ordered pair...
allocated on the heap whose components are the function's multiple return values.)
CPR analysis was introduced in the context of compiling Haskell
Haskell (programming language)
Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...
(a lazy
Lazy evaluation
In programming language theory, lazy evaluation or call-by-need is an evaluation strategy which delays the evaluation of an expression until the value of this is actually required and which also avoids repeated evaluations...
functional language
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...
) and is implemented in the Glasgow Haskell Compiler
Glasgow Haskell Compiler
The Glorious Glasgow Haskell Compilation System, more commonly known as the Glasgow Haskell Compiler or GHC, is an open source native code compiler for the functional programming language Haskell. The lead developers are Simon Peyton Jones and Simon Marlow...
. It may be applicable to other programming languages as well.