Loading AI tools
From Wikipedia, the free encyclopedia
In computer science, Peter Landin's J operator is a programming construct that post-composes a lambda expression with the continuation 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.
This article may be too technical for most readers to understand. (October 2010) |
The J operator was created to make labels and jumps a first class value. It was designed to work with the SECD machine with the following extra transitions:
Transition | From | To |
---|---|---|
J | J:f:S, E, ap:C, D | closure(f,D):S, E, C, D |
Closure | closure(f, (S', E', C', D')):x:S, E, ap:C, D | f:x:S', E', ap:C', D' |
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)) ).
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.
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.
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.