[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Real-life examples of lexical binding in Emacs Lisp
From: |
Pascal J. Bourguignon |
Subject: |
Re: Real-life examples of lexical binding in Emacs Lisp |
Date: |
Thu, 18 Jun 2015 00:17:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Robert Thorpe <rt@robertthorpeconsulting.com> writes:
> Emanuel Berg <embe8573@student.uu.se> writes:
>> I take it "lexical" refers to you can make it out by
>> looking at the code.
>
> Yes.
>
>> "Dynamic" refers to it depends on the code and the
>> program state in execution.
>
> Yes.
>
>> I agree those terms are confusing. To me, it sounds
>> like they refer to call-by-value vs.
>> call-by-reference, which isn't so.
>>
>> I'd call it "normal scope" vs.
>> "stacked scope", perhaps.
>
> Both cases are usually implemented using stacks. Thinking about this
> helps understanding.
>
> In the lexical scope case we can think of one huge stack. Each entry in
> the stack can contain many elements. When execution enters a "let" form
> a new entry is created on the stack and the variables declared there are
> stored in that entry. They "shadow" other variables with the same name
> - they take precedence over them. When execution exits the let form
> that stack entry is deleted. This is usually how lexical scope is
> implement too.
However, contrarily to dynamic binding, lexical binding requires the use
of the heap to implement non-delimited closures.
This is why it was less obvious.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
- Re: Real-life examples of lexical binding in Emacs Lisp, (continued)
- Re: Real-life examples of lexical binding in Emacs Lisp, Udyant Wig, 2015/06/18
- Re: Real-life examples of lexical binding in Emacs Lisp, Emanuel Berg, 2015/06/18
- Re: Real-life examples of lexical binding in Emacs Lisp, Udyant Wig, 2015/06/19
- acronymania (was: Re: Real-life examples of lexical binding in Emacs Lisp), Emanuel Berg, 2015/06/19
- Re: acronymania (was: Re: Real-life examples of lexical binding in Emacs Lisp), Rusi, 2015/06/19
- Message not available
- Re: Real-life examples of lexical binding in Emacs Lisp, Emanuel Berg, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Robert Thorpe, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp,
Pascal J. Bourguignon <=
- Re: Real-life examples of lexical binding in Emacs Lisp, Pascal J. Bourguignon, 2015/06/16
- Re: Real-life examples of lexical binding in Emacs Lisp, Phillip Lord, 2015/06/17
- Message not available
- Re: Real-life examples of lexical binding in Emacs Lisp, Jim Diamond, 2015/06/23
Re: Real-life examples of lexical binding in Emacs Lisp, Stefan Monnier, 2015/06/14