Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Scope (computer science)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== History === Lexical scope was first used in the early 1960s for the imperative language [[ALGOL 60]] and has been picked up in most other imperative languages since then.<ref name=Borning>Borning A. [https://web.archive.org/web/20150207225438/http://courses.cs.washington.edu/courses/cse341/08au/general-concepts/scoping.html CSE 341 -- Lexical and Dynamic Scoping]. University of Washington.</ref> Languages like [[Pascal (programming language)|Pascal]] and [[C (programming language)|C]] have always had lexical scope, since they are both influenced by the ideas that went into [[ALGOL 60]] and [[ALGOL 68]] (although C did not include lexically [[nested function]]s). [[Perl]] is a language with dynamic scope that added static scope afterwards.{{cn|date=January 2025}} The original [[Lisp (programming language)|Lisp]] interpreter (1960) used dynamic scope. ''Deep binding'', which approximates static (lexical) scope, was introduced around 1962 in LISP 1.5 (via the [[Funarg]] device developed by [[Steve Russell (computer scientist)|Steve Russell]], working under [[John McCarthy (computer scientist)|John McCarthy]]). All early [[Lisp (programming language)|Lisps]] used dynamic scope, when based on interpreters. In 1982, Guy L. Steele Jr. and the Common LISP Group published ''An overview of Common LISP'',<ref>{{cite book |last1=Louis Steele |first1=Guy |title=Proceedings of the 1982 ACM symposium on LISP and functional programming - LFP '82 |chapter=An overview of COMMON LISP |date=August 1982 |pages=98β107 |doi=10.1145/800068.802140|isbn=0-89791-082-6 |s2cid=14517358 }}</ref> a short review of the history and the divergent implementations of Lisp up to that moment and a review of the features that a ''Common Lisp'' implementation should have. On page 102, we read: <blockquote>Most LISP implementations are internally inconsistent in that by default the interpreter and compiler may assign different semantics to correct programs; this stems primarily from the fact that the interpreter assumes all variables to be dynamically scoped, while the compiler assumes all variables to be local unless forced to assume otherwise. This has been done for the sake of convenience and efficiency, but can lead to very subtle bugs. The definition of Common LISP avoids such anomalies by explicitly requiring the interpreter and compiler to impose identical semantics on correct programs.</blockquote> Implementations of Common LISP were thus required to have [[Common Lisp#Lexical|lexical scope]]. Again, from ''An overview of Common LISP'': <blockquote>In addition, Common LISP offers the following facilities (most of which are borrowed from MacLisp, InterLisp or Lisp Machines Lisp): (...) Fully lexically scoped variables. The so-called "[[funarg problem|FUNARG problem]]"<ref>{{cite journal |last1=Joel |first1=Moses |title=The Function of FUNCTION in LISP |journal=MIT AI Memo 199 |publisher=MIT Artificial Intelligence Lab |date=June 1970}}</ref><ref>{{cite journal |last1=Steele |first1=Guy Lewis Jr. |last2=Sussman |first2=Gerald Jay |title=The Art of the Interpreter; or, The Modularity Complex (Parts Zero, One and Two). |journal=MIT AI Memo 453 |publisher=MIT Artificial Intelligence Lab |date=May 1978}}</ref> is completely solved, in both the downward and upward cases.</blockquote> By the same year in which ''An overview of Common LISP'' was published (1982), initial designs (also by Guy L. Steele Jr.) of a compiled, lexically scoped Lisp, called ''[[History of the Scheme programming language|Scheme]]'' had been published and compiler implementations were being attempted. At that time, lexical scope in Lisp was commonly feared to be inefficient to implement. In ''A History of T'',<ref>{{cite web |last1=Shivers |first1=Olin |title=History of T |url=http://www.paulgraham.com/thist.html |website=Paul Graham |access-date=5 February 2020}}</ref> Olin Shivers writes: <blockquote>''All'' serious Lisps in production use at that time were dynamically scoped. No one who hadn't carefully read the Rabbit<ref>{{cite tech report |last1=Steele |first1=Guy Lewis Jr. |title=RABBIT: A Compiler for SCHEME |publisher=Massachusetts Institute of Technology |date=May 1978|hdl=1721.1/6913 |hdl-access=free}}</ref> thesis (written by Guy Lewis Steele Jr. in 1978) believed lexical scope would fly; even the few people who ''had'' read it were taking a bit of a leap of faith that this was going to work in serious production use.</blockquote> The term "lexical scope" dates at least to 1967,<ref>"[https://books.google.com/books?id=qk0jAQAAMAAJ&q=%22lexical+scope%22 lexical scope]", {{Google books|qk0jAQAAMAAJ|Computer and Program Organization, Part 3|page=18}}, University of Michigan. Engineering Summer Conferences, 1967</ref> while the term "lexical scoping" dates at least to 1970, where it was used in [[Project MAC]] to describe the scope rules of the Lisp dialect [[MDL (programming language)|MDL]] (then known as "Muddle").<ref> "[https://books.google.com/books?id=m0IdAQAAMAAJ&q=%22lexical+scoping%22 lexical scoping]", {{Google books|m0IdAQAAMAAJ|Project MAC Progress Report, Volume 8|page=80}}, 1970.</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Scope (computer science)
(section)
Add topic