From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rusi Newsgroups: gmane.emacs.help Subject: Re: Real-life examples of lexical binding in Emacs Lisp Date: Sat, 30 May 2015 08:23:24 -0700 (PDT) Message-ID: References: <7b497693-bd08-45c0-99f4-e70836437535@googlegroups.com> <87h9qu6xh8.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1432999518 17067 80.91.229.3 (30 May 2015 15:25:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 May 2015 15:25:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 30 17:25:18 2015 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 1YyidR-0002fb-9N for geh-help-gnu-emacs@m.gmane.org; Sat, 30 May 2015 17:25:17 +0200 Original-Received: from localhost ([::1]:39712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyidQ-0005Zc-EY for geh-help-gnu-emacs@m.gmane.org; Sat, 30 May 2015 11:25:16 -0400 X-Received: by 10.236.40.8 with SMTP id e8mr16418043yhb.35.1432999405280; Sat, 30 May 2015 08:23:25 -0700 (PDT) X-Received: by 10.50.102.71 with SMTP id fm7mr41922igb.8.1432999405230; Sat, 30 May 2015 08:23:25 -0700 (PDT) Original-Path: usenet.stanford.edu!z60no4678322qgd.0!news-out.google.com!n7ni48315igk.0!nntp.google.com!h15no431832igd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <87h9qu6xh8.fsf@kuiper.lan.informatimago.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=117.195.42.176; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui Original-NNTP-Posting-Host: 117.195.42.176 User-Agent: G2/1.0 Injection-Date: Sat, 30 May 2015 15:23:25 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:212401 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:104685 Archived-At: On Saturday, May 30, 2015 at 6:20:13 PM UTC+5:30, Pascal J. Bourguignon wrote: > Rusi writes: > > > I'd say you are getting this from the wrong end. > > Today (2015) dynamic scoping is considered a bug > > "Bug" is too strong a word here. > > > > In 1960 when Lisp was invented of course people did not realize this. > > This is just a belated bug-fix > > It is actually in 1960 (or a few years after) when LISP was invented, > that people realized there was the so called "Funarg problem". During > the 60s this problem has been studied, several (faulty) solutions > proposed, and eventually the notions of lexical binding vs. dynamic > binding and environments were elaborated. I dont understand why the funarg problem is at issue here. If foo calls bar (not nested within foo) And bar references x which it does not define The natural expection is a 'Variable undefined' error. However in a dynamic scoping discipline, you will get the error if foo does NOT define x; else bar will get foo's private x. I dont see how this can be regarded as not buggy -- no need to bring in functional/higher-order aspects at all. > > Other languages such as Fortran and Algol had already something like > lexical binding, but it was actually as accidental as the dynamic > binding of LISP, and of no consequence, since in those languages it was > not possible to create closures anyways. There is somebody-or-other's law (sorry cant remember the reference) to the effect: When a language is designed from ground up it usually gets scoping right. When a language slowly evolves out of mere configuration into more and more features into full Turing-completeness, it invariably gets scoping wrong. Examples (in addition to Lisp): perl, python, lua and most famously javascript I conclude: a. Scoping is a much harder problem than appears at first blush b. Compiled languages tend to get it more right than interpreted