J operator
   HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
,
Peter Landin Peter John Landin (5 June 1930 – 3 June 2009) was a British computer scientist. He was one of the first to realise that the lambda calculus could be used to model a programming language, an insight that is essential to the development of both ...
's J operator is a programming construct that post-composes a lambda expression with the
continuation In computer science, a continuation is an abstract representation of the control state of a computer program. A continuation implements ( reifies) the program control state, i.e. the continuation is a data structure that represents the computat ...
to the current lambda-context. The resulting “function” is first-class and can be passed on to subsequent functions, where if applied it will return its result to the continuation of the function in which it was created.


History

The J operator was created to make labels and jumps a first class value. It was designed to work with the
SECD machine The SECD machine is a highly influential (see: '' Landin's contribution'') virtual machine and abstract machine intended as a target for compilers of functional programming languages. The letters stand for stack, environment, control, dump, respe ...
with the following extra transitions: The J operator originally created what was called a "program closure", consisting of a function called the body and a SECD state called the dump. A program closure is equivalent to composing its body with the dump in continuation form (''closure''(''f'',''D'')(''x)'' = ''D''(''f''(''x'')) ).


Simplified description

The J operator composes a function with the continuation of the calling function. That is, the J operator returns a function, which when applied applies the argument of the J operator with the argument of the function, and then forces the function that called the J operator to return that value.


Examples

J(''λx.x'') is equivalent to a first class return statement. This is because ''λx.x'' is the identity function, so when it gets applied it will do nothing to the value given and returns it straight away. ''λv.''J(''λx.x'') initially returns the J of ''λx.x'', but that could be used in a surrounding expression to make it re-return a different value.


See also

* Call-with-current-continuation


References

; By Landin * * * * Landin, P.J., “A formal description of Algol 60.” Presented at IFIP Working Conf., Baden, Sept. 1964. * Landin, P.J., “Programming without lmperatives—an Example,” UNIVAC S.P. Research Report (March, 1965) * Landin, P.J., “Getting Rid of Labels,” UNIVAC S.P. Research Report (July, 1965) * Landin, P.J., “An Analysis of Assignment in Programming Languages,” UNIVAC S.P. Research Report (September, 1965) *Landin, P.J.
“A Generalization of Jumps and Labels,”math.bas.bg
(1998) ; By others * * * 1965 in computing Control flow Continuations Programming language semantics {{prog-lang-stub