Reputation: 520
I have heard of the "J operator" or "program point operator", when researching about ISWIM. I would like to know what it is. The Wikipedia article for it is very vague:
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.
What does "post-composing" mean? I checked and could only find a mathematical definition. I searched a lot elsewhere and have found very little. There are a few pages that mention it but none describe in detail what it actual is.
So, what is the J operator, what does it do and is it similar to call/cc?
Upvotes: 3
Views: 166
Reputation: 71119
Peter Landin's 1965 article Correspondence between ALGOL 60 and Church's Lambda-notation: part I states:
Consider a definition
f(x) = ... g(...,...) ... where g = Jλ(u,v)
where the subexpression
g(...,...)
may occur at any λ-depth on the right-hand side, and in any context.If during an application of
f
this subexpression is evaluated, its value will immediately become the result produced byf
.
It also cites this paper.
(later edit) What he probably meant is perhaps
f(x) = .... g(...,...) ....
where
g = J foo
foo(u,v) = ....
which in Scheme would be then written as
(define (f x)
(call/cc (lambda (exit)
(define (foo u v) ....)
(define ((J foo) . r) (exit (apply foo r))
(define (g (J foo)))
....
(g ... ...) ; at arbitrary expression depth
.... )))
But his example could arguably be also written as
f(x) = .... Jg(...,...) ....
where
g(u,v) = ....
which in Scheme would be then written as, simpler,
(define (f x)
(define (g u v) ....)
(call/cc (lambda (J)
....
(J (g ... ...)) ; at arbitrary expression depth
.... )))
In both cases it indeed seems to be about exit continuation, defined via call/cc
.
Upvotes: 1