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
Scheme (programming language)
(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!
===Environments and eval=== Prior to R5RS, Scheme had no standard equivalent of the <code>eval</code> procedure which is ubiquitous in other Lisps, although the first Lambda Paper had described <code>evaluate</code> as "similar to the LISP function EVAL"<ref name="lambda_paper_1"/> and the first Revised Report in 1978 replaced this with <code>enclose</code>, which took two arguments. The second, third and fourth revised reports omitted any equivalent of <code>eval</code>. The reason for this confusion is that in Scheme with its lexical scoping the result of evaluating an expression depends on where it is evaluated. For instance, it is not clear whether the result of evaluating the following expression should be 5 or 6:<ref name="rees_1992">Jonathan Rees, [http://mumble.net/~jar/pubs/scheme-of-things/june-92-meeting.ps The Scheme of Things The June 1992 Meeting] {{Webarchive|url=https://web.archive.org/web/20110716071317/http://mumble.net/~jar/pubs/scheme-of-things/june-92-meeting.ps |date=2011-07-16}} (postscript), in Lisp Pointers, V(4), October–December 1992. Retrieved 2012-08-09</ref> <syntaxhighlight lang="Scheme"> (let ((name '+)) (let ((+ *)) (evaluate (list name 2 3)))) </syntaxhighlight> If it is evaluated in the outer environment, where <code>name</code> is defined, the result is the sum of the operands. If it is evaluated in the inner environment, where the symbol "+" has been bound to the value of the procedure "*", the result is the product of the two operands. R5RS resolves this confusion by specifying three procedures that return environments and providing a procedure <code>eval</code> that takes an s-expression and an environment and evaluates the expression in the environment provided. (R5RS sec. 6.5)<ref name="r5rs"/> R6RS extends this by providing a procedure called <code>environment</code> by which the programmer can specify exactly which objects to import into the evaluation environment. With modern scheme (usually compatible with R5RS) to evaluate this expression, one needs to define a function <code>evaluate</code> which can look like this: <syntaxhighlight lang="Scheme"> (define (evaluate expr) (eval expr (interaction-environment))) </syntaxhighlight> <code>interaction-environment</code> is the interpreter's global environment.
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
Scheme (programming language)
(section)
Add topic