help-gnu-emacs
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]