help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: DynamicBindingVsLexicalBinding


From: Dmitry Gutov
Subject: Re: DynamicBindingVsLexicalBinding
Date: Sat, 12 Oct 2013 21:35:56 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Andreas Röhler <address@hidden> writes:

> http://www.emacswiki.org/emacs/DynamicBindingVsLexicalBinding
>
> 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))



reply via email to

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