The Scheme language is standardized in the official [[Institute of Electrical and Electronics Engineers|IEEE]] standard<ref name="ieee1178">1178-1990 (Reaff 2008) IEEE Standard for the Scheme Programming Language. IEEE part number STDPD14209, [http://standards.ieee.org/board/rev/308minutes.html unanimously reaffirmed] at a meeting of the IEEE-SA Standards Board Standards Review Committee (RevCom), March 26, 2008 (item 6.3 on minutes), reaffirmation minutes accessed October 2009. NOTE: this document is only available for purchase from IEEE and is not available online at the time of writing (2009).</ref> <!--
-->and a ''de facto'' standard called the ''Revised{{padlsup|n}} Report on the Algorithmic Language Scheme'' (R''n''RS). A widely implemented standard is R5RS (1998).<ref name="r5rs">{{citeCite journal |authorlast=Richard Kelsey |last2=William Clinger |last3=Jonathan Rees |last4=Rozas |first4=G.J. |last5=Adams Iv |first5=N.I. |last6=Friedman |first6=D.P. |last7=Kohlbecker |first7=E. |last8=Steele Jr. |first8=G.L. |last9=Bartley |first9=D.H. |display-authors=3 |date=August 1998 |title=Revised<sup>5</sup> Report on the Algorithmic Language Scheme |url=http://www.schemers.org/Documents/Standards/R5RS/ |journal=Higher-Order and Symbolic Computation |volume=11 |issue=1 |pages=7–105 |doi=10.1023/A:1010051815785 |access-date=2012-08-09 |author2=William Clinger |author3=Jonathan Rees |display-authors=3 |last4=Rozas |first4=G.J. |last5=Adams Iv |first5=N.I. |last6=Friedman |first6=D.P. |last7=Kohlbecker |first7=E. |last8=Steele Jr. |first8=G.L. |last9=Bartley |first9=D.H.|s2cid=14069423 }}</ref> <!--
-->The most recently ratified standard of Scheme<!--
--> is "R7RS-small" (2013).<ref name="r7rs">{{citeCite web |date=2013-07-06 |title=R7RS final available |url=http://trac.sacrideo.us/wg/raw-attachment/wiki/WikiStart/r7rs.pdf}}</ref> The more expansive and modular R6RS was ratified in 2007.<ref name="r6rs">{{citeCite web |last1last=Sperber |first1first=Michael |last2=Dybvig |first2=R. Kent |last3=Flatt |first3=Matthew |last4=Van Straaten |first4=Anton |display-authors=etal |date=August 2007 |title=Revised<sup>6</sup> Report on the Algorithmic Language Scheme (R6RS) |url=http://www.r6rs.org |access-date=2011-09-13 |publisher=Scheme Steering Committee}}</ref> Both trace their descent from R5RS; the timeline below reflects the chronological order of ratification.<!--
-->
===Origins===
Scheme started in the 1970s as an attempt to understand [[Carl Hewitt]]'s [[Actor model]], for which purpose Steele and Sussman wrote a "tiny Lisp interpreter" using [[Maclisp]] and then "added mechanisms for creating actors and sending messages".<ref name="revisited">{{citeCite journal |last1last=Sussman |first1first=Gerald Jay |last2=Steele |first2=Guy L. |date=1 December 1998 |title=The First Report on Scheme Revisited |journal=Higher-Order and Symbolic Computation |date=1 December 1998 |volume=11 |issue=4 |pages=399–404 |doi=10.1023/A:1010079421970 |s2cid=7704398 }}</ref> Scheme was originally called "Schemer", in the tradition of other [[Lisp (programming language)|Lisp]]-derived languages such as [[Planner (programming language)|Planner]] or ''Conniver''. The current name resulted from the authors' use of the [[Incompatible Timesharing System|ITS operating system]], which limited filenames to two components of at most six characters each. Currently, "Schemer" is commonly used to refer to a Scheme programmer.
===R6RS===
R6RS features a standard module system, allowing a split between the core language and libraries. A number of drafts of the R6RS specification were released, the final version being R5.97RS. A successful vote resulted in the ratification of the new standard, announced on August 28, 2007.<ref name="r6rs" />
Currently the newest releases of various Scheme implementations<ref name="rs6s_Implementations">{{citeCite web |title=R6RS Implementations |url=http://www.r6rs.org/implementations.html |title=R6RS Implementations |publisher=r6rs.org |access-date=2017-11-24 |publisher=r6rs.org}}</ref> support the R6RS standard. There is a portable reference implementation of the proposed implicitly phased libraries for R6RS, called psyntax, which loads and bootstraps itself properly on various older Scheme implementations.<ref name="psyntax">{{citeCite web |authorlast=Abdulaziz Ghuloum |publisherdate=Ikarus2007-10-27 Scheme|title=R6RS Libraries and syntax-case system (psyntax) |url=https://www.cs.indiana.edu/~aghuloum/r6rs-libraries/ |title=R6RS Libraries and syntax-case system (psyntax) |date=2007-10-27 |access-date=2009-10-20 |publisher=Ikarus Scheme}}</ref>
A feature of R6RS is the record-type descriptor (RTD). When an RTD is created and used, the record type representation can show the memory layout. It also calculated object field bit mask and mutable Scheme object field bit masks, and helped the garbage collector know what to do with the fields without traversing the whole fields list that are saved in the RTD. RTD allows users to expand the basic RTD to create a new record system.<ref>{{citeCite journal |last1last=Keep |first1first=Andrew W. |last2=Dybvig |first2=R. Kent |date=November 2014 |title=A run-time representation of scheme record types |journal=Journal of Functional Programming |date=November 2014 |volume=24 |issue=6 |pages=675–716 |doi=10.1017/S0956796814000203 |s2cid=40001845 }}</ref>
R6RS introduces numerous significant changes to the language.<ref name="r6rs_Language_changes">{{citeCite web |publisherdate=Scheme Steering Committee2007-09-26 |title=Revised^6 Report on the Algorithmic Language Scheme, Appendix E: language changes |url=http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-19.html#node_chap_E |date=2007-09-26 |access-date=2009-10-20 |publisher=Scheme Steering Committee}}</ref> The source code is now specified in [[Unicode]], and a large subset of Unicode characters may now appear in Scheme symbols and [[identifier]]s, and there are other minor changes to the lexical rules. Character data is also now specified in Unicode. Many standard procedures have been moved to the new standard libraries, which themselves form a large expansion of the standard, containing procedures and syntactic forms that were formerly not part of the standard. A new module system has been introduced, and systems for exception handling are now standardized. Syntax-rules has been replaced with a more expressive syntactic abstraction facility (syntax-case) which allows the use of all of Scheme at macro expansion time. Compliant implementations are now ''required'' to support Scheme's full [[Numerical tower|numeric tower]], and the semantics of numbers have been expanded, mainly in the direction of support for the [[IEEE 754-1985|IEEE 754]] standard for floating point numerical representation.
===R7RS===
The R6RS standard has caused controversy because some see it as a departure from the minimalist philosophy.<ref name="r6rs_electorate">{{citeCite web |publisheryear=Scheme2007 Steering|title=R6RS CommitteeElectorate |url=http://www.r6rs.org/ratification/electorate.html |title=R6RS Electorate |year=2007 |access-date=2012-08-09 |publisher=Scheme Steering Committee}}</ref><ref name="r6rs_feeley">{{citeCite web |authorlast=Marc Feeley (compilation) |publisherdate=Scheme2007-10-26 Steering|title=Implementors' Committee,intentions r6rs-discussconcerning mailing listR6RS |url=http://lists.r6rs.org/pipermail/r6rs-discuss/2007-October/003351.html |title=Implementors' intentions concerning R6RS |date=2007-10-26 |access-date=2012-08-09 |publisher=Scheme Steering Committee, r6rs-discuss mailing list}}</ref> In August 2009, the Scheme Steering Committee, which oversees the standardization process, announced its intention to recommend splitting Scheme into two languages: a large modern programming language for programmers; and a small version, a subset of the large version retaining the minimalism praised by educators and casual implementors.<ref name="position_paper">{{citeCite web |authorlast=Will Clinger, Marc Feeley, Chris Hanson, Jonathan Rees and Olin Shivers |date=2009-08-20 |title=Position Statement ''(draft)'' |url=http://scheme-reports.org/2009/position-statement.html |access-date=2012-08-09 |publisher=Scheme Steering Committee}}</ref> Two working groups were created to work on these two new versions of Scheme. The Scheme Reports Process site has links to the working groups' charters, public discussions and issue tracking system.
The ninth draft of R7RS (small language) was made available on April 15, 2013.<ref name="r7rs-draft-9">{{citeCite web |date=2013-04-15 |title=R7RS 9th draft available |url=http://trac.sacrideo.us/wg/raw-attachment/wiki/WikiStart/r7rs-draft-9.pdf |title=R7RS 9th draft available |date=2013-04-15}}</ref> A vote ratifying this draft closed on May 20, 2013,<ref name="r7rs_clinger">{{citeCite web |authorlast=Will Clinger |publisherdate=Scheme2013-05-10 Language|title=extension Steeringof Committee,voting scheme-reports mailing listperiod |url=http://lists.scheme-reports.org/pipermail/scheme-reports/2013-May/003401.html |title=extension of voting period |date=2013url-05-10 |access-datestatus=2013-07-07dead |archive-url=https://web.archive.org/web/20130721162308/http://lists.scheme-reports.org/pipermail/scheme-reports/2013-May/003401.html# |archive-date=2013-07-21 |urlaccess-statusdate=dead2013-07-07 |publisher=Scheme Language Steering Committee, scheme-reports mailing list}}</ref> and the final report has been available since August 6, 2013,<!-- quote= the Scheme Steering Committee decided in August 2009 to divide the standard into two separate but compatible languages – a "small" language, suitable for educators, researchers, and users of embedded languages, focused on R5RS compatibility, and a "large" language focused on the practical needs of mainstream software development, intended to become a replacement for R6RS. The present report --> describing "the 'small' language of that effort: therefore it cannot be considered in isolation as the successor to R6RS".<ref name="r7rs">{{cite web |url=http://trac.sacrideo.us/wg/raw-attachment/wiki/WikiStart/r7rs.pdf |title=R7RS final available |date=2013-07-06}}</ref>
{{Lisp}}
===Minimalism===
{{Main|Minimalism (computing)}}
Scheme is a very simple language, much easier to implement than many other languages of comparable [[Expressive power (computer science)|expressive power]].<ref name="easy_to_implement_scheme48">The [[Scheme 48]] implementation is so-named because the interpreter was written by Richard Kelsey and Jonathan Rees in 48 hours (August 6th{{spndash}}7th, 1986. See {{citeCite web |publisher=Jonathan Rees, s48.org |author1last=Richard Kelsey |author2last2=Jonathan Rees |author3last3=Mike Sperber |date=2008-01-10 |title=The Incomplete Scheme 48 Reference Manual for release 1.8 |url=http://s48.org/1.8/manual/manual.html |date=2008-01-10 |access-date=2012-08-09 |publisher=Jonathan Rees, s48.org}}</ref> This ease is attributable to the use of [[lambda calculus]] to derive much of the syntax of the language from more primitive forms. For instance of the 23 s-expression-based syntactic constructs defined in the R5RS Scheme standard, 14 are classed as derived or library forms, which can be written as macros involving more fundamental forms, principally lambda. As R5RS (§3.1) says: "The most fundamental of the variable binding constructs is the lambda expression, because all other variable binding constructs can be explained in terms of lambda expressions."<ref name="r5rs"/>
: '''Fundamental forms''': define, lambda, quote, if, define-syntax, let-syntax, letrec-syntax, syntax-rules, set!
Thus using <code>let</code> as defined above a Scheme implementation would rewrite "<code>(let ((a 1)(b 2)) (+ b a))</code>" as "<code>((lambda (a b) (+ b a)) 1 2)</code>", which reduces implementation's task to that of coding procedure instantiations.
In 1998, Sussman and Steele remarked that the minimalism of Scheme was not a conscious design goal, but rather the unintended outcome of the design process. "We were actually trying to build something complicated and discovered, serendipitously, that we had accidentally designed something that met all our goals but was much simpler than we had intended....we realized that the lambda calculus—a small, simple formalism—could serve as the core of a powerful and expressive programming language."<ref name="revisited" />
===Lexical scope===
Like most modern programming languages and unlike earlier Lisps such as [[Maclisp]], Scheme is lexically scoped: all possible variable bindings in a program unit can be analyzed by reading the text of the program unit without consideration of the contexts in which it may be called. This contrasts with dynamic scoping which was characteristic of early Lisp dialects, because of the processing costs associated with the primitive textual substitution methods used to implement lexical scoping algorithms in compilers and interpreters of the day. In those Lisps, it was perfectly possible for a reference to a [[free variable]] inside a procedure to refer to quite distinct bindings external to the procedure, depending on the context of the call.
The impetus to incorporate lexical scoping, which was an unusual scoping model in the early 1970s, into their new version of Lisp, came from Sussman's studies of [[ALGOL]]. He suggested that [[Block (programming)|ALGOL-like lexical scoping mechanisms]] would help to realize their initial goal of implementing [[Carl Hewitt#Actor model|Hewitt's Actor model]] in Lisp.<ref name="revisited" />
The key insights on how to introduce lexical scoping into a Lisp dialect were popularized in Sussman and Steele's 1975 Lambda Paper, "Scheme: An Interpreter for Extended Lambda Calculus",<ref name="lambda_paper_1">{{citeCite journal |author1last=Gerald Jay Sussman |author2last2=Guy Lewis Steele Jr. |name-list-style=amp |date=December 1975 |title=Scheme: An Interpreter for Extended Lambda Calculus |url=https://dspace.mit.edu/bitstream/handle/1721.1/5794/AIM-349.pdf |journal=AI Memos |publisher=[[MIT Computer Science and Artificial Intelligence Laboratory|MIT AI Lab]] |journal=AI Memos |volume=AIM-349 |date=December 1975 |url=https://dspace.mit.edu/bitstream/handle/1721.1/5794/AIM-349.pdf|access-date=23 December 2021 |hdl=1721.1/5794 }}</ref> where they adopted the concept of the [[Closure (computer science)|lexical closure]] (on page 21), which had been described in an [[AI Memo]] in 1970 by [[Joel Moses]], who attributed the idea to [[Peter J. Landin]].<!--
--><ref name="Moses">{{citationCitation |authorlast=Joel Moses |date=June 1970 |title=The Function of FUNCTION in LISP, or Why the FUNARG Problem Should Be Called the Environment Problem |date=June 1970 |id=[[AI Memo]] 199 |author-link=Joel Moses |quote=A useful metaphor for the difference between FUNCTION and QUOTE in LISP is to think of QUOTE as a porous or an open covering of the function since free variables escape to the current environment. FUNCTION acts as a closed or nonporous covering (hence the term "closure" used by Landin). Thus we talk of "open" Lambda expressions (functions in LISP are usually Lambda expressions) and "closed" Lambda expressions. [...] My interest in the environment problem began while Landin, who had a deep understanding of the problem, visited MIT during 1966-67. I then realized the correspondence between the FUNARG lists which are the results of the evaluation of "closed" Lambda expressions in [[LISP 1.5|LISP]] and [[ISWIM]]'s Lambda Closures. |author-link=Joel Moses |hdl=1721.1/5854 }}</ref>
===Lambda calculus===
{{See also|Lambda calculus}}
[[Alonzo Church]]'s mathematical notation, the lambda calculus, has inspired Lisp's use of "lambda" as a keyword for introducing a procedure, as well as influencing the development of [[functional programming]] techniques involving the use of [[higher-order function]]s in Lisp. But early Lisps were not suitable expressions of the lambda calculus because of their treatment of [[Free variables and bound variables|free variables]].<ref name="revisited" />
A formal lambda system has axioms and a complete calculation rule. It is helpful for the analysis using mathematical logic and tools. In this system, calculation can be seen as a directional deduction. The syntax of lambda calculus follows the recursive expressions from x, y, z, ...,parentheses, spaces, the period and the symbol λ.<ref>{{citeCite journal |last1last=van Tonder |first1first=André |date=1 January 2004 |title=A Lambda Calculus for Quantum Computation |journal=SIAM Journal on Computing |date=1 January 2004 |volume=33 |issue=5 |pages=1109–1135 |arxiv=quant-ph/0307150 |doi=10.1137/S0097539703432165 |arxiv=quant-ph/0307150 |s2cid=613571 }}</ref> The function of lambda calculation includes: First, serve as a starting point of powerful mathematical logic. Second, it can reduce the requirement of programmers to consider the implementation details, because it can be used to imitate machine evaluation. Finally, the lambda calculation created a substantial meta-theory.<ref>{{citeCite journal |last1last=Niehren |first1first=J. |last2=Schwinghammer |first2=J. |last3=Smolka |first3=G. |date=November 2006 |title=A concurrent lambda calculus with futures |url=https://hal.inria.fr/inria-00090434/file/0.pdf |journal=Theoretical Computer Science |date=November 2006 |volume=364 |issue=3 |pages=338–356 |doi=10.1016/j.tcs.2006.08.016 |url=https://hal.inria.fr/inria-00090434/file/0.pdf }}</ref>
The introduction of lexical scope resolved the problem by making an equivalence between some forms of lambda notation and their practical expression in a working programming language. Sussman and Steele showed that the new language could be used to elegantly derive all the imperative and declarative semantics of other programming languages including ALGOL and [[Fortran]], and the dynamic scope of other Lisps, by using lambda expressions not as simple procedure instantiations but as "control structures and environment modifiers".<ref name="lambda_paper_2">{{citeCite journal |author1last=Gerald Jay Sussman |author2last2=Guy Lewis Steele Jr. |name-list-style=amp |date=March 1976 |title=Lambda: The Ultimate Imperative |url=http://library.readscheme.org/page1.html |url-status=dead |format=postscript or PDF |journal=AI Memos |publisher=[[MIT Computer Science and Artificial Intelligence Laboratory|MIT AI Lab]] |journal=AI Memos |volume=AIM-353 |date=March 1976 |url=http://library.readscheme.org/page1.html |format=postscript or PDF |access-date=2012-08-09 |archive-url=https://web.archive.org/web/20160510140804/http://library.readscheme.org/page1.html |archive-date=2016-05-10 |urlaccess-statusdate=dead 2012-08-09}}</ref> They introduced [[continuation-passing style]] along with their first description of Scheme in the first of the Lambda Papers, and in subsequent papers, they proceeded to demonstrate the raw power of this practical use of lambda calculus.
===Block structure===
===Shared namespace for procedures and variables===
In contrast to Common Lisp, all data and procedures in Scheme share a common namespace, whereas in Common Lisp [[Common Lisp#The function namespace|functions and data have separate namespaces]] making it possible for a function and a variable to have the same name, and requiring special notation for referring to a function as a value. This is sometimes known as the "[[Lisp-1 vs. Lisp-2]]" distinction, referring to the unified namespace of Scheme and the separate namespaces of Common Lisp.<ref>{{citeCite news |last1last=Gabriel |first1first=Richard P. |author-link=Richard P. Gabriel |last2=Pitman |first2=Kent |author2author-linklink2=Kent Pitman |publication-dateyear=June 1988 |title=Technical Issues of Separation in Function Cells and Value Cells |periodicalvolume=1 |pages=81–101 |work=Lisp and Symbolic Computation |volumeissue=1 |issuepublication-date=1June |pages=81–1011988 |url=http://www.nhplace.com/kent/Papers/Technical-Issues.html |access-date=2012-08-09 |doi=10.1007/BF01806178 |year=1988 }}</ref>
In Scheme, the same primitives that are used to manipulate and bind data can be used to bind procedures. There is no equivalent of Common Lisp's <code>defun</code> and <code>#'</code> primitives.
The lexical context of the original definition of the promise is preserved, and its value is also preserved after the first use of <code>force</code>. The promise is only ever evaluated once.
These primitives, which produce or handle values known as [[Futures and promises|promises]], can be used to implement advanced [[lazy evaluation]] constructs such as [[stream (computing)|stream]]s.<ref name="srfi-41">{{citeCite web |publisherlast=ThePhilip SRFIL. Editors,Bewig schemers.org|date=2008-01-24 |authortitle=PhilipSRFI L.41: BewigStreams |url=http://srfi.schemers.org/srfi-41/srfi-41.html |title=SRFI 41: Streams |date= 2008-01-24 |access-date=2012-08-09 |publisher=The SRFI Editors, schemers.org}}</ref>
In the R6RS standard, these are no longer primitives, but instead, are provided as part of the R5RS compatibility library (rnrs r5rs (6)).
In R5RS, a suggested implementation of <code>delay</code> and <code>force</code> is given, implementing the promise as a procedure with no arguments (a [[thunk]]) and using [[memoization]] to ensure that it is only ever evaluated once, irrespective of the number of times <code>force</code> is called (R5RS sec. 6.4).<ref name="r5rs"/>
SRFI 41 enables the expression of both finite and infinite sequences with extraordinary economy. For example, this is a definition of the [[fibonacci number|fibonacci sequence]] using the functions defined in SRFI 41:<ref name="srfi-41" />
<syntaxhighlight lang="Scheme">
===Hygienic macros===
{{Main|Hygienic macro}}
In the R5RS standard and also in later reports, the syntax of Scheme can easily be extended via the macro system. The R5RS standard introduced a powerful hygienic macro system that allows the programmer to add new syntactic constructs to the language using a simple [[pattern matching]] sublanguage (R5RS sec 4.3).<ref name="r5rs"/> Prior to this, the hygienic macro system had been relegated to an appendix of the R4RS standard, as a "high level" system alongside a "low level" macro system, both of which were treated as extensions to Scheme rather than an essential part of the language.<ref name="r4rs">{{citeCite journal |year=1991 |title=Revised<sup>4</sup> Report on the Algorithmic Language Scheme |editor=William Clinger and Jonathan Rees|url=http://www.cs.indiana.edu/scheme-repository/R4RS/r4rs_toc.html |journal=ACM Lisp Pointers |volume=4 |issue=3 |pages=1–55 |year=1991 |access-date=2012-08-09 |editor=William Clinger and Jonathan Rees}}</ref>
Implementations of the hygienic macro system, also called <code>syntax-rules</code>, are required to respect the lexical scoping of the rest of the language. This is assured by special naming and scoping rules for macro expansion and avoids common programming errors that can occur in the macro systems of other programming languages. R6RS specifies a more sophisticated transformation system, <code>syntax-case</code>, which has been available as a language extension to R5RS Scheme for some time.
Most Scheme implementations also provide additional macro systems. Among popular ones are [[Hygienic macro#syntactic closures|syntactic closures]], [[Hygienic macro#explicit renaming|explicit renaming macros]] and <code>define-macro</code>, a non-hygienic macro system similar to <code>defmacro</code> system provided in [[Common Lisp]].
The inability to specify whether or not a macro is hygienic is one of the shortcomings of the macro system. Alternative models for expansion such as scope sets provide a potential solution.<ref>{{citeCite book |doilast=10.1145/2837614.2837620Flatt |chapterfirst=Binding as sets of scopesMatthew |title=Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages |year=2016 |last1=Flatt |first1=Matthew |pages=705–717 |isbn=978-1-4503-3549-2 |pages=705–717 |chapter=Binding as sets of scopes |doi=10.1145/2837614.2837620 |s2cid=15401805 }}</ref>
===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.
===Treatment of non-boolean values in boolean expressions===
In most dialects of Lisp including Common Lisp, by convention the value <code>NIL</code> evaluates to the value false in a boolean expression. In Scheme, since the IEEE standard in 1991,<ref name="ieee1178" /> all values except #f, including <code>NIL</code>'s equivalent in Scheme which is written as '(), evaluate to the value true in a boolean expression. (R5RS sec. 6.3.1)<ref name="r5rs" />
Where the constant representing the boolean value of true is <code>T</code> in most Lisps, in Scheme it is <code>#t</code>.
===Comments===
{{See also|Comment (computer programming)}}
Up to the R5RS standard, the standard comment in Scheme was a semicolon, which makes the rest of the line invisible to Scheme. Numerous implementations have supported alternative conventions permitting comments to extend for more than a single line, and the R6RS standard permits two of them: an entire [[s-expression]] may be turned into a comment (or "commented out") by preceding it with <code><nowiki>#;</nowiki></code> (introduced in SRFI 62<ref>{{citeCite web |publisher=The SRFI Editors, schemers.org |authorlast=Taylor Campbell |date=2005-07-21 |title=SRFI 62: S-expression comments |url=http://srfi.schemers.org/srfi-62/srfi-62.html |access-date=2012-08-09 |publisher=The SRFI Editors, schemers.org}}</ref>) and a multiline comment or "block comment" may be produced by surrounding text with <code><nowiki>#</nowiki>|</code> and <code>|#</code>.
===Input/output===
Scheme's input and output is based on the ''port'' datatype. (R5RS sec 6.6)<ref name="r5rs"/> R5RS defines two default ports, accessible with the procedures <code>current-input-port</code> and <code>current-output-port</code>, which correspond to the Unix notions of [[Standard streams|standard input and standard output]]. Most implementations also provide <code>current-error-port</code>. [[Redirection (computing)|Redirection]] of input and standard output is supported in the standard, by standard procedures such as <code>with-input-from-file</code> and <code>with-output-to-file</code>. Most implementations provide string ports with similar redirection capabilities, enabling many normal input-output operations to be performed on string buffers instead of files, using procedures described in SRFI 6.<ref name="srfi-6">{{citeCite web |publisher=The SRFI Editors, schemers.org |authorlast=William D Clinger |date=1999-07-01 |title=SRFI 6: Basic String Ports |url=http://srfi.schemers.org/srfi-6/srfi-6.html |access-date=2012-08-09 |publisher=The SRFI Editors, schemers.org}}</ref> The R6RS standard specifies much more sophisticated and capable port procedures and many new types of port.
The following examples are written in strict R5RS Scheme.
Similar procedures are provided for input. R5RS Scheme provides the predicates <code>input-port?</code> and <code>output-port?</code>. For character input and output, <code>write-char</code>, <code>read-char</code>, <code>peek-char</code> and <code>char-ready?</code> are provided. For writing and reading Scheme expressions, Scheme provides <code>read</code> and <code>write</code>. On a read operation, the result returned is the end-of-file object if the input port has reached the end of the file, and this can be tested using the predicate <code>eof-object?</code>.
In addition to the standard, SRFI 28 defines a basic formatting procedure resembling Common Lisp's <code>format</code> function, after which it is named.<ref name="srfi-28">{{citeCite web |publisher=The SRFI Editors, schemers.org |authorlast=Scott G. Miller |date=2002-06-25 |title=SRFI 28: Basic Format Strings |url=http://srfi.schemers.org/srfi-28/srfi-28.html |access-date=2012-08-09 |publisher=The SRFI Editors, schemers.org}}</ref>
===Redefinition of standard procedures===
The form of the titles of the standards documents since R3RS, "Revised<sup>n</sup> Report on the Algorithmic Language Scheme", is a reference to the title of the [[ALGOL|ALGOL 60]] standard document, "Revised Report on the Algorithmic Language Algol 60," The Summary page of R3RS is closely modeled on the Summary page of the ALGOL 60 Report.<!--
--><ref name="algol_report">{{citeCite journal |urllast=http://wwwJ.masswerkW.at/algol60/report Backus |last2=F.htmL. Bauer |last3=J.Green |last4=C. Katz |last5=J. McCarthy P. Naur |display-authors=etal |date=January–April 1960 |title=Revised Report on the Algorithmic Language Algol 60 |authorurl=Jhttp://www.Wmasswerk. Backusat/algol60/report.htm |journal=Numerische Mathematik, Communications of the ACM, and Journal of the British Computer Society |date=January–April 1960 |access-date=2012-08-09 |author2=F.L. Bauer |author3=J.Green |author4=C. Katz |author5=J. McCarthy P. Naur |display-authors=etal}}</ref><ref name="r3rs">{{citeCite journal |editordate=JonathanDecember Rees1986 |editor2-last=William Clinger |journal=ACM SIGPLAN Notices |date=December 1986 |volume=21 |issue=12 |pages=37–79 |title=Revised(3) Report on the Algorithmic Language Scheme (Dedicated to the Memory of ALGOL 60) |url=http://groups.csail.mit.edu/mac/ftpdir/scheme-reports/r3rs-html/r3rs_toc.html |access-datejournal=2012-08-09ACM SIGPLAN Notices |volume=21 |issue=12 |pages=37–79 |citeseerx=10.1.1.29.3015 |doi=10.1145/15042.15043 |access-date=2012-08-09 |editor=Jonathan Rees |hdl=1721.1/6424 |citeseerx=10.1.1.29.3015 |s2cid=43884422 }}</ref>
== Review of standard forms and procedures ==
Because of Scheme's minimalism, many common procedures and syntactic forms are not defined by the standard. In order to keep the core language small but facilitate standardization of extensions, the Scheme community has a "Scheme Request for Implementation" (SRFI) process by which extension libraries are defined through careful discussion of extension proposals. This promotes code portability. Many of the SRFIs are supported by all or most Scheme implementations.
SRFIs with fairly wide support in different implementations include:<ref name="srfi_support">{{citeCite web |publisher=The SRFI Editors, schemers.org |date=2009-08-30 |title=Scheme Systems Supporting SRFIs |url=http://srfi.schemers.org/srfi-implementers.html |title=Scheme Systems Supporting SRFIs |access-date=2012-08-09 |publisher=The SRFI Editors, schemers.org}}</ref>
* 0: feature-based conditional expansion construct
{{maincat|Scheme (programming language) implementations}}
The elegant, minimalist design has made Scheme a popular target for language designers, hobbyists, and educators, and because of its small size, that of a typical [[Interpreter (computing)|interpreter]], it is also a popular choice for [[embedded system]]s and [[scripting language|scripting]]. This has resulted in scores of implementations,<ref name="scheme_implementations">75 known implementations of Scheme are listed by {{citeCite web |publisherdate=Community2009-06-25 Scheme Wiki|title=scheme-faq-standards |url=http://community.schemewiki.org/?scheme-faq-standards#implementations |title= schemeaccess-faq-standards |date=2009-0610-2520 |access-datepublisher=2009-10-20Community Scheme Wiki}}</ref> most of which differ from each other so much that porting programs from one implementation to another is quite difficult, and the small size of the standard language means that writing a useful program of any great complexity in standard, portable Scheme is almost impossible.<ref name="position_paper" /> The R6RS standard specifies a much broader language, in an attempt to broaden its appeal to programmers.
Almost all implementations provide a traditional Lisp-style [[read–eval–print loop]] for development and debugging. Many also [[Compiler|compile]] Scheme programs to executable binary. Support for embedding Scheme code in programs written in other languages is also common, as the relative simplicity of Scheme implementations makes it a popular choice for adding scripting capabilities to larger systems developed in languages such as [[C (programming language)|C]]. The [[Gambit (Scheme implementation)|Gambit]], [[Chicken (Scheme implementation)|Chicken]], and [[Bigloo]] Scheme interpreters compile Scheme to C, which makes embedding particularly easy. In addition, Bigloo's compiler can be configured to generate [[Java Virtual Machine|JVM]] [[bytecode]], and it also features an experimental bytecode generator for [[.NET Framework|.NET]].
== Usage ==
Scheme is widely used by a number<ref name="schemers_inc">{{citeCite web |publisherlast=SchemersEd Inc.Martin |authordate=Ed Martin2009-07-20 |title=List of Scheme-using schools |url=http://www.schemers.com/schools.html |access-date=2009-0710-20 |access-datepublisher=2009-10-20Schemers Inc.}}</ref> of schools; in particular, a number of introductory [[Computer Science]] courses use Scheme in conjunction with the textbook ''[[Structure and Interpretation of Computer Programs]]'' (SICP).<ref name="sicp_adopters">{{citeCite web |publisherdate=MIT1999-01-26 Press|title=List of SICP-using schools |url=http://mitpress.mit.edu/sicp/adopt-list.html |title=List of SICP-using schools |date=1999-01-26 |access-date=2009-10-20 |publisher=MIT Press}}</ref> For the past 12 years, [[Racket (programming language)|PLT]] has run the [[ProgramByDesign]] (formerly TeachScheme!) project, which has exposed close to 600 high school teachers and thousands of high school students to rudimentary Scheme programming. [[MIT]]'s old introductory programming class 6.001 was taught in Scheme,<ref name="6.001">{{citeCite web |publisher=MIT Open Courseware |authorlast=Eric Grimson |author-link=Eric Grimson |date=Spring 2005 |title=6.001 Structure and Interpretation of Computer Programs |url=http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/CourseHome/index.htm |title=6.001 Structure and Interpretation of Computer Programs |date=Spring 2005 |access-date=2009-10-20 |publisher=MIT Open Courseware}}</ref> Although 6.001 has been replaced by more modern courses, SICP continues to be taught at MIT.<ref name="6.001_zombies">{{citeCite web |publisher=MIT CSAIL |authorlast=Alex Vandiver |author2last2=Nelson Elhage |display-authors=etal |date=January 2009 |title=6.184 - Zombies drink caffeinated 6.001 |url=http://web.mit.edu/alexmv/6.001/ |date=January 2009 |access-date=2009-10-20 |publisher=MIT CSAIL}}</ref> Likewise, the introductory class at [[UC Berkeley]], CS 61A, was until 2011 taught entirely in Scheme, save minor diversions into Logo to demonstrate dynamic scope. Today, like MIT, Berkeley has replaced the syllabus with a more modern version that is primarily taught in [[Python (programming language)|Python 3]], but the current syllabus is still based on the old curriculum, and parts of the class are still taught in Scheme.<ref name="61A">{{citeCite web |last=John DeNero |date=Fall 2019 |title=Computer Science 61A, Berkeley |url=https://cs61a.org/articles/about.html|title=Computer Science 61A, Berkeley|author=John DeNero|access-date=Fall 2019-12-17 |publisher=Department of Electrical Engineering and Computer Sciences, Berkeley|access-date=2019-12-17}}</ref>
The textbook ''[[How to Design Programs]]'' by Matthias Felleisen, currently at Northeastern University, is used by some institutes of higher education for their introductory computer science courses. Both [[Northeastern University]] and [[Worcester Polytechnic Institute]] use Scheme exclusively for their introductory courses Fundamentals of Computer Science (CS2500) and Introduction to Program Design (CS1101), respectively.<ref name="neu">[http://www.ccs.neu.edu/course/cs2500/ CS 2500: Fundamentals of Computer Science I], [[Northeastern University]]</ref><ref name="wpi">[http://web.cs.wpi.edu/~cs1101/a05/details.html#software CS 1101: Introduction to Program Design (A05): course software], [[Worcester Polytechnic Institute]]</ref> [[Rose-Hulman]] uses Scheme in its more advanced Programming Language Concepts course.<ref name="rhit">{{citeCite web |title=CSSE 304: Programming Language Concepts |url=https://www.rose-hulman.edu/Users/faculty/young/CS-Classes/csse304/syllabus.html|title=CSSE 304: Programming Language Concepts|publisher=[[Rose-Hulman Institute of Technology]]}}</ref> [[Brandeis University]]'s core course, Structure and Interpretations of Computer Programs (COSI121b), is also taught exclusively in Scheme by theoretical computer scientist [[Harry Mairson]].<ref name="brandeis">{{citeCite web |title=Spring 2021 CS121b Syllabus |url=https://moodle2.brandeis.edu/syllabus/public/1202dcdfe19c0860e226f6447f66875c.pdf|title=Spring 2021 CS121b Syllabus|publisher=[[Brandeis University]]}}</ref> [[Indiana University]]'s introductory class, C211, is taught entirely in Scheme. A self-paced version of the course, CS 61AS, continues to use Scheme.<ref>https://berkeley-cs61as.github.io</ref> The introductory computer science courses at [[Yale]] and [[Grinnell College]] are also taught in Scheme.<ref name="yale_cs201">{{citeCite web |authorlast=Dana Angluin |publisherdate=TheFall Zoo,2009 Yale|title=Introduction Universityto Computer Science Department(CPSC 201) |url=http://zoo.cs.yale.edu/classes/cs201/ |title=Introduction to Computer Science (CPSC 201) |date=Fall 2009 |access-date=2009-10-20 |publisher=The Zoo, Yale University Computer Science Department}}</ref> Programming Design Paradigms,<ref name="neu2">{{citeCite web |publisherdate=NortheasternFall University2009 College|title=Programming ofDesign ComputerParadigms andCSG107 InformationCourse ScienceReadings |url=http://www.ccs.neu.edu/home/matthias/107-f08/readings.html |titleaccess-date=Programming2012-08-09 Design|publisher=Northeastern ParadigmsUniversity CSG107College Courseof ReadingsComputer |date=Falland 2009Information |access-date=2012-08-09Science}}</ref> a mandatory course for the Computer science Graduate Students at [[Northeastern University]], also extensively uses Scheme.
The former introductory Computer Science course at the University of Minnesota - Twin Cities, CSCI 1901, also used Scheme as its primary language, followed by a course that introduced students to the Java programming language;<ref name="umn">[http://www-users.itlabs.umn.edu/classes/Spring-2010/csci1901/ Structure of Computer Programming I] {{Webarchive|url=https://web.archive.org/web/20100619111110/http://www-users.itlabs.umn.edu/classes/Spring-2010/csci1901/# |date=2010-06-19 }}, Computer Science Department, University of Minnesota, Spring 2010 (accessed 2010-01-30).</ref> however, following the example of MIT, the department replaced 1901 with the Python-based CSCI 1133,<ref name="umn2">[https://www.cs.umn.edu/academics/undergraduate/curriculum/required CSci Required Class Course Descriptions and Other Information] {{Webarchive|url=https://web.archive.org/web/20191025145152/https://www.cs.umn.edu/academics/undergraduate/curriculum/required |date=2019-10-25}}, Computer Science Department, University of Minnesota (accessed 2019-10-25)</ref> while functional programming is covered in detail in the third-semester course CSCI 2041.<ref name="umn3">[https://www.csdy.umn.edu/~shield/csecc/minutes/2013-4-23/csci2041.html CSCI 2041—New Course] CSE Curriculum Committee, University of Minnesota (accessed 2019-10-25)</ref> In the software industry, [[Tata Consultancy Services]], Asia's largest software consultancy firm, uses Scheme in their month-long training program for fresh college graduates.{{citation needed|date=August 2013}}
Scheme is/was also used for the following:
* The [[Document Style Semantics and Specification Language]] (DSSSL), which provides a method of specifying [[SGML]] [[Style sheet (web development)|stylesheet]]s, uses a Scheme subset.<ref name="dsssl">{{citeCite web |publisher=Cover Pages |authorlast=Robin Cover |urldate=http://xml.coverpages.org/dsssl.html2002-02-25 |title=DSSSL - Document Style Semantics and Specification Language. ISO/IEC 10179:1996 |dateurl=2002-02-25http://xml.coverpages.org/dsssl.html |access-date=2012-08-09 |publisher=Cover Pages}}</ref>
* The well-known [[Open-source software|open source]] [[raster graphics editor]] [[GIMP]] uses [[TinyScheme]] as a [[scripting language]].<ref name="gimp">"''The major scripting language for the GIMP that has been attached to it today is Scheme.''" From {{citeCite web |authorlast=Dov Grobgeld |publisheryear=The GIMP Team2002 |title=The GIMP Basic Scheme Tutorial |url=http://www.gimp.org/tutorials/Basic_Scheme/ |year=2002 |access-date=2012-08-09 |publisher=The GIMP Team}}</ref>
* [[GNU Guile|Guile]] has been adopted by [[GNU]] project as its official scripting language, and that implementation of Scheme is embedded in such applications as [[GNU LilyPond]] and [[GnuCash]] as a scripting language for extensions. Likewise, Guile used to be the scripting language for the [[desktop environment]] [[GNOME]],<ref name="archive_gnomefaq">{{citeCite web |url=http://www.gnome.org/gnomefaq/html/x930.html |author1last=Todd Graham Lewis |author2last2=David Zoll |author3last3=Julian Missig |publisheryear=The Gnome Team, gnome.org2002 |title=GNOME FAQ from Internet Archive |yearurl=2002 |access-date=2012-08-09http://www.gnome.org/gnomefaq/html/x930.html |archive-url=https://web.archive.org/web/20000522010523/http://www.gnome.org/gnomefaq/html/x930.html |archive-date=2000-05-22 |access-date=2012-08-09 |publisher=The Gnome Team, gnome.org}}</ref> and GNOME still has a project that provides Guile bindings to its library stack.<ref name="live_gnome">{{citeCite web |publishertitle=Free Software Foundationguile-gnome |url=https://www.gnu.org/software/guile-gnome/ |title=guile-gnome |access-date=2012-08-09 |publisher=Free Software Foundation}}</ref> There is a project to incorporate Guile into [[GNU Emacs]], GNU's flagship program, replacing the current [[Emacs Lisp]] interpreter.{{ Citation needed | reason=Where is the source? | date=May 2019 }}
* [[Extension Language Kit|Elk Scheme]] is used by [[Synopsys]] as a scripting language for its [[Technology CAD|technology CAD (TCAD)]] tools.<ref name="tcad">{{citeCite web |urllast=http://www.synopsys.com/community/interoperability/documents/devforum_pres/2006nov/milkywaysession_mapin_overview.pdfLaurence Brevard |date=2006-11-09 |title=Synopsys MAP-in<sup>SM</sup> Program Update: EDA Interoperability Developers' Forum |publisherurl=Synopsis Inc |author=Laurence Brevard |date=2006-11-09http://www.synopsys.com/community/interoperability/documents/devforum_pres/2006nov/milkywaysession_mapin_overview.pdf |access-date=2012-08-09 |publisher=Synopsis Inc}}</ref>
* Shiro Kawai, senior programmer on the movie ''[[Final Fantasy: The Spirits Within]]'', used Scheme as a scripting language for managing the real-time rendering engine.<ref name="shiro_kawai">{{citeCite journal |last=Kawai |first=Shiro |date=October 2002 |title=Gluing Things Together - Scheme in the Real-time CG Content Production |url=http://practical-scheme.net/docs/ILC2002.html |journal=Proceedings of the First International Lisp Conference, San Francisco |date=October 2002 |pages=342–348 |url=http://practical-scheme.net/docs/ILC2002.html |access-date=2012-08-09 }}</ref>
* [[Google App Inventor]] for [[Android (operating system)|Android]] uses Scheme, where [[Kawa (Scheme implementation)|Kawa]] is used to compile the Scheme code down to byte-codes for the [[Java Virtual Machine]] running on Android devices.<ref name="android">{{citeCite web |publisher=Google Inc, Official Google Research blog |author1last=Bill Magnuson |author2last2=Hal Abelson |author3last3=Mark Friedman |name-list-style=amp |date=2009-08-11 |title=Under the Hood of App Inventor for Android |date=2009-08-11 |url=http://googleresearch.blogspot.com/2009/08/under-hood-of-app-inventor-for-android.html |access-date=2012-08-09 |publisher=Google Inc, Official Google Research blog}}</ref>
== See also ==
== Further reading ==
* [ftp://ftp.cs.utexas.edu/pub/garbage/cs345/schintro-v14/schintro_toc.html An Introduction to Scheme and its Implementation] ([http://icem-www.folkwang-hochschule.de/~finnendahl/cm_kurse/doc/schintro/schintro_toc.html a mirror])
* {{citeCite web |authorlast=Christopher T. Haynes |date=1999-06-22 |title=The Scheme Programming Language Standardization Experience |url=http://acm.org/tsc/sstd.html}}
* {{citeCite web |authorlast=[[Guy L. Steele Jr.]], [[Richard P. Gabriel]] |title=The Evolution of Lisp |url=http://www.dreamsongs.org/Files/HOPL2-Uncut.pdf }}
* {{cite wikisource |author1=Gerald Jay Sussman|author1-link=Gerald Sussman |author2=Guy Lewis Steele Jr.|author2-link=Guy Steele|name-list-style=amp |title=Scheme: An Interpreter for Extended Lambda Calculus |publisher=[[MIT Computer Science and Artificial Intelligence Laboratory|MIT Artificial Intelligence Lab]] |volume=AI Memo 349 |date=December 1975|citeseerx=10.1.1.128.80}}
|