[Top][All Lists]

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

Re: e and pi

From: Uday S Reddy
Subject: Re: e and pi
Date: Sat, 18 Sep 2010 22:37:02 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100915 Thunderbird/3.1.4

On 9/18/2010 8:10 PM, Chong Yidong wrote:

You came up with this

   (defun make-inc (e)
     (lambda (m) (+ e m)))

   (let ((f (make-inc 3)))
     (funcall f 5))

I agree that static scoping is much better in this example.  But we
could fix this simply by imposing static scope on function arguments.
So, is there an equivalent scenario in which the proposed change to
`let' is clearly desireable?

Consider this:

(defvar funny nil)
(let ((e 25))
   (setq funny (lambda (m) (+ e m))))

Now, (funcall funny 2) should return 27. Instead, with dynamic binding, it returns 4.7182...

The point is not whether `e' is being bound in a let or a defun. Rather, the point is that we should be able to use a variable like `e' as a free variable in a closure. We can do so only if it is governed by lexical binding.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]