unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* lexical-binding rationale?
@ 2012-01-12 16:47 Dave Abrahams
  2012-01-12 18:01 ` Alan Mackenzie
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Dave Abrahams @ 2012-01-12 16:47 UTC (permalink / raw)
  To: emacs-devel


I'm sure this has been discussed to death, so please feel free to
respond with a link, but... can anyone point me to a rationale for
dynamically altering such a fundamental language behavior on the basis
of a variable's value?

Thanks,

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 16:47 lexical-binding rationale? Dave Abrahams
@ 2012-01-12 18:01 ` Alan Mackenzie
  2012-01-12 18:50   ` Dave Abrahams
  2012-01-12 20:51 ` Glenn Morris
  2012-01-13  5:17 ` Richard Stallman
  2 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2012-01-12 18:01 UTC (permalink / raw)
  To: Dave Abrahams; +Cc: emacs-devel

On Thu, Jan 12, 2012 at 11:47:35AM -0500, Dave Abrahams wrote:

Request for clarification:

> I'm sure this has been discussed to death, so please feel free to
> respond with a link, but... can anyone point me to a rationale for
> dynamically altering such a fundamental language behavior on the basis
> of a variable's value?

What, exactly does "dynamically altering" mean?
What is the "fundamental language behaviour" which is being/to be
  dynamically altered.
What precise relationship has been abstracted to "on the basis of"?
Which "variable's value" is meant here.

Or, more succinctly, what the heck are you going on about?

> Thanks,

> -- 
> Dave Abrahams

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 18:50   ` Dave Abrahams
@ 2012-01-12 18:49     ` Alan Mackenzie
  0 siblings, 0 replies; 13+ messages in thread
From: Alan Mackenzie @ 2012-01-12 18:49 UTC (permalink / raw)
  To: Dave Abrahams; +Cc: emacs-devel

On Thu, Jan 12, 2012 at 01:50:33PM -0500, Dave Abrahams wrote:

> on Thu Jan 12 2012, Alan Mackenzie <acm-AT-muc.de> wrote:

> > On Thu, Jan 12, 2012 at 11:47:35AM -0500, Dave Abrahams wrote:

> > Request for clarification:

> >> I'm sure this has been discussed to death, so please feel free to
> >> respond with a link, but... can anyone point me to a rationale for
> >> dynamically altering such a fundamental language behavior on the
> >> basis of a variable's value?

> > What, exactly does "dynamically altering" mean?

> Sorry, that's a very dangerous term developed in secret at the
> U.S. Department of Redundancy Department.

> Let's just say, "altering"

> > What is the "fundamental language behaviour" which is being/to be
> > dynamically altered.  
> > What precise relationship has been abstracted to "on the basis of"?
> > Which "variable's value" is meant here.

> My understanding is that Emacs is using a buffer-local variable called
> `lexical-binding' to determine whether variable bindings shall be
> dynamic or lexical.

OK, got you now!  Thanks.

> -- 
> Dave Abrahams

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 18:01 ` Alan Mackenzie
@ 2012-01-12 18:50   ` Dave Abrahams
  2012-01-12 18:49     ` Alan Mackenzie
  0 siblings, 1 reply; 13+ messages in thread
From: Dave Abrahams @ 2012-01-12 18:50 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel


on Thu Jan 12 2012, Alan Mackenzie <acm-AT-muc.de> wrote:

> On Thu, Jan 12, 2012 at 11:47:35AM -0500, Dave Abrahams wrote:
>
> Request for clarification:
>
>> I'm sure this has been discussed to death, so please feel free to
>> respond with a link, but... can anyone point me to a rationale for
>> dynamically altering such a fundamental language behavior on the basis
>> of a variable's value?
>
> What, exactly does "dynamically altering" mean?

Sorry, that's a very dangerous term developed in secret at the
U.S. Department of Redundancy Department.

Let's just say, "altering"

> What is the "fundamental language behaviour" which is being/to be
> dynamically altered.  
> What precise relationship has been abstracted to "on the basis of"?
> Which "variable's value" is meant here.

My understanding is that Emacs is using a buffer-local variable called
`lexical-binding' to determine whether variable bindings shall be
dynamic or lexical.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 16:47 lexical-binding rationale? Dave Abrahams
  2012-01-12 18:01 ` Alan Mackenzie
@ 2012-01-12 20:51 ` Glenn Morris
  2012-01-12 22:00   ` Stefan Monnier
  2012-01-13  5:17 ` Richard Stallman
  2 siblings, 1 reply; 13+ messages in thread
From: Glenn Morris @ 2012-01-12 20:51 UTC (permalink / raw)
  To: Dave Abrahams; +Cc: emacs-devel

Dave Abrahams wrote:

> I'm sure this has been discussed to death, so please feel free to
> respond with a link, but... can anyone point me to a rationale for
> dynamically altering such a fundamental language behavior on the basis
> of a variable's value?

It's easy to use on a per-file basis, and in the majority of cases
allows the source to be transparently backwards compatible with
older/other versions of Emacs; so why not. Since it's a fait accompli,
discussing alternative ways it might have been done are only going to be
of academic interest.

I never did get an answer to my question about whether the setting HAS
to go in the first line of the file though. I still don't know.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8610#8



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 20:51 ` Glenn Morris
@ 2012-01-12 22:00   ` Stefan Monnier
  2012-01-13  7:55     ` Glenn Morris
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2012-01-12 22:00 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Dave Abrahams, emacs-devel

>> I'm sure this has been discussed to death, so please feel free to
>> respond with a link, but... can anyone point me to a rationale for
>> dynamically altering such a fundamental language behavior on the basis
>> of a variable's value?
> It's easy to use on a per-file basis, and in the majority of cases
> allows the source to be transparently backwards compatible with
> older/other versions of Emacs; so why not. Since it's a fait accompli,
> discussing alternative ways it might have been done are only going to be
> of academic interest.
> I never did get an answer to my question about whether the setting HAS
> to go in the first line of the file though. I still don't know.
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8610#8

The intention is that it should work like any other file-local setting
so it can go in the end as well, but I haven't checked that
lisp_file_lexically_bound_p handles that cases correctly.  If it
doesn't, then the file would be mis-handled when loading it uncompiled
(which is the only case where lisp_file_lexically_bound_p is used).


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 16:47 lexical-binding rationale? Dave Abrahams
  2012-01-12 18:01 ` Alan Mackenzie
  2012-01-12 20:51 ` Glenn Morris
@ 2012-01-13  5:17 ` Richard Stallman
  2012-01-13 15:28   ` Dave Abrahams
  2 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2012-01-13  5:17 UTC (permalink / raw)
  To: Dave Abrahams; +Cc: emacs-devel

    I'm sure this has been discussed to death, so please feel free to
    respond with a link, but... can anyone point me to a rationale for
    dynamically altering such a fundamental language behavior on the basis
    of a variable's value?

It has to be specified somehow, so how would you suggest?

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use free telephony http://directory.fsf.org/category/tel/



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-12 22:00   ` Stefan Monnier
@ 2012-01-13  7:55     ` Glenn Morris
  2012-01-14  2:30       ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Glenn Morris @ 2012-01-13  7:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Dave Abrahams, emacs-devel

Stefan Monnier wrote:

> The intention is that it should work like any other file-local setting
> so it can go in the end as well, but I haven't checked that
> lisp_file_lexically_bound_p handles that cases correctly.

Just from looking at it, it sure looks like it doesn't.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-13  5:17 ` Richard Stallman
@ 2012-01-13 15:28   ` Dave Abrahams
  2012-01-13 18:37     ` Stefan Monnier
  2012-01-14  0:59     ` Ted Zlatanov
  0 siblings, 2 replies; 13+ messages in thread
From: Dave Abrahams @ 2012-01-13 15:28 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel


on Fri Jan 13 2012, Richard Stallman <rms-AT-gnu.org> wrote:

>     I'm sure this has been discussed to death, so please feel free to
>     respond with a link, but... can anyone point me to a rationale for
>     dynamically altering such a fundamental language behavior on the basis
>     of a variable's value?
>
> It has to be specified somehow, so how would you suggest?

Maybe it's fine the way it is.  My impression was that it was going to
be affected by a local variable setting in the current buffer, but IIUC
it is a local variable setting in the buffer from which elisp is being
read (? this isn't entirely clear—and it should be—from the
documentation).

If so, that gives me less of a cause for worry.  My initial reaction
when I heard about this was that we should have a set of
functions/macros for lexical binding, e.g. (lex-let ((a b)(c d)) (body))
but then, as I say, I may have misunderstood what was happening.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-13 15:28   ` Dave Abrahams
@ 2012-01-13 18:37     ` Stefan Monnier
  2012-01-13 19:19       ` Dave Abrahams
  2012-01-14  0:59     ` Ted Zlatanov
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2012-01-13 18:37 UTC (permalink / raw)
  To: Dave Abrahams; +Cc: rms, emacs-devel

> Maybe it's fine the way it is.  My impression was that it was going to
> be affected by a local variable setting in the current buffer, but IIUC
> it is a local variable setting in the buffer from which elisp is being
> read (? this isn't entirely clear—and it should be—from the
> documentation).

Right.  The variable is looked up when calling `eval', not when
processing let-bindings.  So indeed it is the value in the buffer from
which the code was `read' that is important, rather than the value in
the buffer that happens to be current when a new binding is created.


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-13 18:37     ` Stefan Monnier
@ 2012-01-13 19:19       ` Dave Abrahams
  0 siblings, 0 replies; 13+ messages in thread
From: Dave Abrahams @ 2012-01-13 19:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: rms, emacs-devel


on Fri Jan 13 2012, Stefan Monnier <monnier-AT-iro.umontreal.ca> wrote:

>> Maybe it's fine the way it is.  My impression was that it was going to
>> be affected by a local variable setting in the current buffer, but IIUC
>> it is a local variable setting in the buffer from which elisp is being
>> read (? this isn't entirely clear—and it should be—from the
>> documentation).
>
> Right.  The variable is looked up when calling `eval', not when
> processing let-bindings.  So indeed it is the value in the buffer from
> which the code was `read' that is important, rather than the value in
> the buffer that happens to be current when a new binding is created.

IMO it's a documentation bug that I had to ask that question.  Could
someone please fix that?

Thanks,

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-13 15:28   ` Dave Abrahams
  2012-01-13 18:37     ` Stefan Monnier
@ 2012-01-14  0:59     ` Ted Zlatanov
  1 sibling, 0 replies; 13+ messages in thread
From: Ted Zlatanov @ 2012-01-14  0:59 UTC (permalink / raw)
  To: emacs-devel

On Fri, 13 Jan 2012 10:28:53 -0500 Dave Abrahams <dave@boostpro.com> wrote: 

DA> My initial reaction when I heard about this was that we should have
DA> a set of functions/macros for lexical binding, e.g. (lex-let ((a
DA> b)(c d)) (body)) but then, as I say, I may have misunderstood what
DA> was happening.

Wait, you know about `lexical-let', right?

Ted




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: lexical-binding rationale?
  2012-01-13  7:55     ` Glenn Morris
@ 2012-01-14  2:30       ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2012-01-14  2:30 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Dave Abrahams, emacs-devel

>> The intention is that it should work like any other file-local setting
>> so it can go in the end as well, but I haven't checked that
>> lisp_file_lexically_bound_p handles that cases correctly.
> Just from looking at it, it sure looks like it doesn't.

Hmm... indeed!

I guess lisp_file_lexically_bound_p should largely be rewritten by
moving it to load-with-code-conversion/load-source-file-function.
This said, now that I see the code it's clear that if we care about the
performance of loading .el (i.e. uncompiled) files, then we should force
lexical-binding to be on the first line.  Of course, currently it looks
like we don't care about this performance (that's probably the reason
why people have started to see a real speed up when compiling their
.emacs file), but if we want to be able to change our minds, we'd better
impose the restriction right away because afterwards will be too late.


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-01-14  2:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-12 16:47 lexical-binding rationale? Dave Abrahams
2012-01-12 18:01 ` Alan Mackenzie
2012-01-12 18:50   ` Dave Abrahams
2012-01-12 18:49     ` Alan Mackenzie
2012-01-12 20:51 ` Glenn Morris
2012-01-12 22:00   ` Stefan Monnier
2012-01-13  7:55     ` Glenn Morris
2012-01-14  2:30       ` Stefan Monnier
2012-01-13  5:17 ` Richard Stallman
2012-01-13 15:28   ` Dave Abrahams
2012-01-13 18:37     ` Stefan Monnier
2012-01-13 19:19       ` Dave Abrahams
2012-01-14  0:59     ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).