[Top][All Lists]

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

Re: DynamicBindingVsLexicalBinding

From: Andreas Röhler
Subject: Re: DynamicBindingVsLexicalBinding
Date: Sun, 13 Oct 2013 09:54:37 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0

Am 12.10.2013 20:35, schrieb Dmitry Gutov:
Andreas Röhler <address@hidden> writes:

it's said WRT lexical binding

"Because it's (1) much easier for the user [that is, programmer], because
it eliminates the problem of which variables lambda-expressions use
(when they attempt to use variables from their surrounding context)"

Unfortunately couldn't find a use-case where it is easier - while consenting it 
might be easier for the compiler to swallow.

Could someone give an example, where lexical binding makes coding easier?

Consider this rather obvious higher-order function:

(defun addinator (a)
   (lambda (b)
     (+ a b)))

;; This doesn't work with dynamic binding, at all
(funcall (addinator 3) 4)

;; This returns wrong result with dynamic binding
(let ((a 42))
   (funcall (addinator 3) 4))

That's interesting, but can hand-over functions also with dynamic binding.

Do you have a real use-case where lexical-binding is superior?

Can't see goodies from lexical binding beside a simplification for the compiler.

reply via email to

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