[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 <andreas.roehler@easy-emacs.de> 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))
- DynamicBindingVsLexicalBinding, Andreas Röhler, 2013/10/12
- Re: DynamicBindingVsLexicalBinding,
Dmitry Gutov <=
- RE: DynamicBindingVsLexicalBinding, Drew Adams, 2013/10/12
- Re: DynamicBindingVsLexicalBinding, Andreas Röhler, 2013/10/13
- Re: DynamicBindingVsLexicalBinding, Kai Großjohann, 2013/10/13
- RE: DynamicBindingVsLexicalBinding, Drew Adams, 2013/10/13
- Re: DynamicBindingVsLexicalBinding, Phillip Lord, 2013/10/14
- RE: DynamicBindingVsLexicalBinding, Drew Adams, 2013/10/14
- Re: DynamicBindingVsLexicalBinding, Phillip Lord, 2013/10/14
- Re: DynamicBindingVsLexicalBinding, Kai Großjohann, 2013/10/14
- Re: DynamicBindingVsLexicalBinding, Phillip Lord, 2013/10/15