[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple LAMBDA evaluations



Your counter examples do not disprove my claim.  In all cases no
lambda expression is evaluated twice in the same environment.  The two
environments (as with JAR's example) may be isomorphic (same variables
and same values), but not identical.  In the absence of incremental
definition, or if there is no handle to these environments, the
distinction is moot, but in the presence of these "features" they are
not the same.  I guess that the difference is that I view environments
as objects (probably influneced because of our dialect), and
conceptually a new one is created every time a lambda expression is
applied, even if this lambda expression has no bindings.

I think that the only cases which force re-evaluation in the same environment
(the way I view them) are contorted examples like

(define fact
  (let ((there&then '()))
    (set! there&then
	  (call-with-current-continuation
	   (lambda (here&now) here&now)))
    (let ((y-like (lambda (x) (there&then x))))		;HERE
      (y-like (lambda (f)
		(lambda (n)
		  (if (= n 0)
		      1
		      (* n ((f f) (-1+ n))))))))))

Note that the 2 lambdas marked by HERE (the explicit one, and the
implicit one in the LET expression) are evaluated twice in the
environment created by the outermost LET.