From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.help Subject: Re: DynamicBindingVsLexicalBinding Date: Sat, 12 Oct 2013 21:35:56 +0300 Message-ID: <871u3qjq0j.fsf@yandex.ru> References: <52598D4A.2010901@easy-emacs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1381602985 12553 80.91.229.3 (12 Oct 2013 18:36:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Oct 2013 18:36:25 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org List" To: Andreas =?utf-8?Q?R=C3=B6hler?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 12 20:36:29 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 1VV43A-0008QB-LV for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Oct 2013 20:36:28 +0200 Original-Received: from localhost ([::1]:59046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VV43A-0000Rx-9T for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Oct 2013 14:36:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VV42u-0000Rp-PC for help-gnu-emacs@gnu.org; Sat, 12 Oct 2013 14:36:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VV42p-0005l7-Op for help-gnu-emacs@gnu.org; Sat, 12 Oct 2013 14:36:12 -0400 Original-Received: from mail-ea0-x233.google.com ([2a00:1450:4013:c01::233]:38404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VV42p-0005ko-Hz for help-gnu-emacs@gnu.org; Sat, 12 Oct 2013 14:36:07 -0400 Original-Received: by mail-ea0-f179.google.com with SMTP id b10so2527797eae.38 for ; Sat, 12 Oct 2013 11:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=vigSYeHobwDrhoqKmOukiWQ/cojNI9NtTACN1+3A7Dg=; b=XgAxcG3l2oqMnaqUFsjhKvCMVTaXjgWZjFhWNDnGU90Sqg/LnNrhA0CG/XZVwo4Y9c 01lTgNRECa2Y95vl/iX6feqoa6y0OXJao7z6Lc+XWmps1F8+/3lcnouCfhz+GnSb+BCr HnV+TX6UhMOlNmVrdNprHXHLBGxqZ7UBhXOrSdkzxcrdZuy9m8JtFuAOr+/p+zCpWpNu VFb0a+hILUZeBuxabHtNJMD0ZMlkhTsUbreBvoKGcyPKW0N/ZgYj82dxHzOML9bhb/eY 6RjkAQEtPtcofheb+ZhHdAYNs1sIImO7/bI+6qcZPt7BbPoQEg+sqebZQpzcrImuccp/ 02ug== X-Received: by 10.15.33.132 with SMTP id c4mr40569758eev.2.1381602966360; Sat, 12 Oct 2013 11:36:06 -0700 (PDT) Original-Received: from axl (93-113-74.netrun.cytanet.com.cy. [93.109.113.74]) by mx.google.com with ESMTPSA id k7sm130657214eeg.13.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 12 Oct 2013 11:36:05 -0700 (PDT) In-Reply-To: <52598D4A.2010901@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6h\?\= \=\?utf-8\?Q\?ler\=22's\?\= message of "Sat, 12 Oct 2013 19:56:26 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::233 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:93960 Archived-At: Andreas R=C3=B6hler 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 consent= ing 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))