all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rusi <rustompmody@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Real-life examples of lexical binding in Emacs Lisp
Date: Sat, 30 May 2015 09:21:33 -0700 (PDT)	[thread overview]
Message-ID: <e3f8088f-697f-4237-a937-9ad27775e66a@googlegroups.com> (raw)
In-Reply-To: <878uc66p53.fsf@kuiper.lan.informatimago.com>

On Saturday, May 30, 2015 at 9:20:19 PM UTC+5:30, Pascal J. Bourguignon wrote:
> Rusi  writes:
> 
> > 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.
> 
> It's not buggy, because it's the behavior of this tools.
> 
> You cannot complain that chainsaw section arms and legs: this is the
> behavior of chainsaws.  Just learn how to use them for good use: section
> only trees or zombies.
> 
> 
> The funarg problem shows that what was wanted with the introduction of
> lambda was not dynamic binding, but lexical binding, so that closures
> could be created by lambda.

Heh!
If scope leaks in straightforward first-order code you say its 
what-you-ask-that-you-get -- chainsaw.
If scope leaks (downward funarg) or breaks (upward funarg) you say the scoping
is at fault.
You're having it both ways aint you Pascal?!

> 
> 
> >> 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
> 
> When LISP was designed, the notion of scoping was just not considered.

This much we can agree

> It's the invention of LISP and the detection of the funarg problem that
> made people think about it, and eventually invent lexical binding and
> environments.

Please see the Algol report www.masswerk.at/algol60/report.htm
The notion of block is fundamental there
In fact the scheme report RnRS used to to trace scheme's lineage as much to
Algol as to Lisp. The Algol contribution was block structure.


  reply	other threads:[~2015-05-30 16:21 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3883.1432888152.904.help-gnu-emacs@gnu.org>
2015-05-29  9:30 ` Real-life examples of lexical binding in Emacs Lisp Joost Kremers
2015-05-29 11:12   ` Andreas Röhler
2015-05-29 12:13     ` Dmitry Gutov
2015-05-29 16:21     ` Phillip Lord
2015-05-29 16:50       ` Yuri Khan
2015-05-29 12:28 ` Pascal J. Bourguignon
2015-05-29 17:16   ` Andreas Röhler
2015-05-29 18:43 ` Emanuel Berg
2015-05-30  5:49 ` Rusi
2015-05-30 12:50   ` Pascal J. Bourguignon
2015-05-30 15:23     ` Rusi
2015-05-30 15:50       ` Pascal J. Bourguignon
2015-05-30 16:21         ` Rusi [this message]
2015-05-30 16:03   ` Emanuel Berg
2015-05-30 16:32     ` Rusi
2015-05-30 16:54       ` Pascal J. Bourguignon
2015-05-30 17:10         ` Rusi
2015-05-30 19:12           ` Pascal J. Bourguignon
2015-05-29  8:28 Marcin Borkowski
2015-05-30  8:28 ` Tassilo Horn
2015-06-14 10:52   ` Marcin Borkowski
     [not found]   ` <mailman.4976.1434279182.904.help-gnu-emacs@gnu.org>
2015-06-14 11:31     ` Pascal J. Bourguignon
2015-06-16 23:48       ` Jim Diamond
2015-06-17  0:06         ` Emanuel Berg
2015-06-17  6:23           ` Andreas Röhler
     [not found]           ` <mailman.5136.1434522217.904.help-gnu-emacs@gnu.org>
2015-06-17 10:49             ` Pascal J. Bourguignon
2015-06-17 10:53               ` Pascal J. Bourguignon
2015-06-17 14:42                 ` Stefan Monnier
2015-06-17 16:19                   ` Andreas Röhler
2015-06-17 19:30                     ` Tassilo Horn
     [not found]                   ` <mailman.5171.1434557990.904.help-gnu-emacs@gnu.org>
2015-06-17 17:12                     ` Stefan Monnier
2015-06-17 20:22                   ` Emanuel Berg
2015-06-17 22:13                     ` Pascal J. Bourguignon
2015-06-17 23:46                       ` Emanuel Berg
2015-06-18 14:57                     ` Udyant Wig
2015-06-18 15:47                       ` Emanuel Berg
2015-06-19 13:49                         ` Udyant Wig
2015-06-17 20:33             ` Emanuel Berg
2015-06-17 22:07               ` Robert Thorpe
2015-06-17 22:17                 ` Pascal J. Bourguignon
2015-06-17  0:43         ` Pascal J. Bourguignon
2015-06-17 16:02         ` Phillip Lord
     [not found]         ` <mailman.5167.1434556959.904.help-gnu-emacs@gnu.org>
2015-06-23 23:49           ` Jim Diamond
     [not found] ` <mailman.3950.1432974543.904.help-gnu-emacs@gnu.org>
2015-05-30 12:59   ` Pascal J. Bourguignon
2015-06-14 10:55     ` Marcin Borkowski
     [not found]     ` <mailman.4977.1434279342.904.help-gnu-emacs@gnu.org>
2015-06-14 20:04       ` Stefan Monnier
2015-06-14 21:44         ` Pascal J. Bourguignon
2015-06-14 21:49           ` Pascal J. Bourguignon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3f8088f-697f-4237-a937-9ad27775e66a@googlegroups.com \
    --to=rustompmody@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.