From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?= Newsgroups: gmane.emacs.help Subject: Re: DynamicBindingVsLexicalBinding Date: Sun, 13 Oct 2013 09:54:37 +0200 Message-ID: <525A51BD.5040903@easy-emacs.de> References: <52598D4A.2010901@easy-emacs.de> <871u3qjq0j.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1381650754 3638 80.91.229.3 (13 Oct 2013 07:52:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Oct 2013 07:52:34 +0000 (UTC) To: "help-gnu-emacs@gnu.org List" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 13 09:52:38 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VVGTb-0002G5-8y for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Oct 2013 09:52:35 +0200 Original-Received: from localhost ([::1]:60617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVGTa-00031G-Dj for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Oct 2013 03:52:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVGTM-00030H-16 for help-gnu-emacs@gnu.org; Sun, 13 Oct 2013 03:52:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVGTG-00072J-GV for help-gnu-emacs@gnu.org; Sun, 13 Oct 2013 03:52:19 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.187]:52670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVGTG-000710-71 for help-gnu-emacs@gnu.org; Sun, 13 Oct 2013 03:52:14 -0400 Original-Received: from purzel.sitgens (brln-4db93dc7.pool.mediaWays.net [77.185.61.199]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0M9vlQ-1VbuIW0Kim-00Bfq9; Sun, 13 Oct 2013 09:52:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: <871u3qjq0j.fsf@yandex.ru> X-Provags-ID: V02:K0:qoThCs9MMMNiKzU0YY7cDYI6IDDmjAmMsroQcZThiTn 9FXRvSx94sZGJPTXGXyznERui5KKnv/4ZcLrDq8Ui/pHs341xn GJLBFAPGO/ihF3k2MODfeH8EECSrDm8Iokyxw/5hOxu/pIalxm Tj1lQWikJAv9CdkPvsQDK5+geNnMxeyVPChJX/1mRWRhhQ+oCr exGjtorjACeDJryk0tBcsY+EfOpuwRMjIJLJDbJVgvWWq2ijNo yuBmYmSfBsbE/XCe5NPpfN3yK+zhEQ43IM4HUF4sRjzC1uwbgO iMTW5c0OyLBaUIDrSxev3FyRDzcgmnLCHXHteuWLvZ3GLjIdpS 9A3xBD9a+6XQukWi4isHe4JSxPJJiqEgcNcOa42td X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.126.187 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93980 Archived-At: Am 12.10.2013 20:35, schrieb Dmitry Gutov: > Andreas Röhler 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)) > 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.