Tracy,
On Wed, Jan 14, 2009 at 21:27, Tracy Harms <[email protected]> wrote:
> I've been putting some attention to "lifting," starting with lambda
> lifting. This is another concept that seems to get a good deal of
> attention in functional-programming circles, except when Iverson
> languages such as J are in mind. It looks to me like array-support
> covers much of what lifting is designed to accomplish.
>
> For example, the Wikipedia article on this topic
> http://en.wikipedia.org/wiki/Lambda_lifting
> contains an OCaml example where the same result can be written in J as +/i.101
It looks to me, based solely on that Wikipedia page, as though lambda
lifting is an compiler technique. The two OCaml programs given are
equivalent. Thus ...
> From the comparison between the OCaml and the J I might conclude that
> J provides transparent lambda lifting. My guess, however, is that such
> a claim would be inaccurate because lambda lifting involves producing
> recursive equations.
Given the above, I'm not sure this is true. Lambda lifting appears to
involve a small and well defined set of manipulations on a given
program, designed to eliminate reference to variables across function
boundaries. The benefit is in eliminating constructs which, while
convenient for the programmer, get in the way of optimisation.
I don't see anything intrinsically recursive about lambda lifting. One
might just as well apply it to an inner function used in an iterative
context. In Common Lisp:
(let ((x 100)
(total 0))
(flet ((f () (+ total x)))
(do ()
((= x 0))
(setf total (f))
(setf x (- x 1))))
total)
Translates, by lambda lifting f, into:
(defun f (p1 p2) (+ p1 p2))
(let ((x 100)
(total 0))
(do ()
((= x 0))
(setf total (f total x))
(setf x (- x 1)))
total)
I presume, however, that a function which _assigns_ to a free variable
cannot be lambda lifted.
Cheers,
Hamish
--
Hamish Harvey
Research Associate, School of Civil Engineering and Geosciences,
Newcastle University
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm