Content deleted Content added
→Usage: Adding to Scheme's usage (Brandeis University) |
Northeastern University no longer uses Scheme-based languages, due to administrative incompetence Tag: references removed |
||
(72 intermediate revisions by 51 users not shown) | |||
Line 1:
{{
{{Infobox programming language
| name = Scheme
| logo =
| logo size = 121px
| paradigms = [[Multi-paradigm programming language|Multi-paradigm]]: [[
| family = [[Lisp (programming language)|Lisp]]
| year = {{Start date and age|1975}}
| designers = [[Guy L. Steele]]
| latest release version = R7RS
| latest release date = {{Start date and age|2013}}
Line 15 ⟶ 16:
| operating system =
| license =
| website = {{URL|https://www.scheme.org/}}
| file_ext = .scm, .ss
| implementations = Many<br/>(see [[:Category:Scheme (programming language) implementations|Scheme implementations]])
| influenced by = [[ALGOL]], [[Lisp (programming language)|Lisp]], [[MDL (programming language)|MDL]]
| influenced = [[Clojure]], [[Common Lisp]], [[Dylan (programming language)|Dylan]], [[EuLisp]], [[
| wikibooks = Scheme
}}
'''Scheme''' is a [[programming language dialect|dialect]] of the [[Lisp (programming language)|Lisp]] family of [[programming language]]s. Scheme was created during the 1970s at the [[MIT Computer Science and Artificial Intelligence Laboratory
The Scheme language is standardized in the official [[Institute of Electrical and Electronics Engineers
▲Scheme was created during the 1970s at the [[MIT Computer Science and Artificial Intelligence Laboratory|MIT AI Lab]] and released by its developers, [[Guy L. Steele]] and [[Gerald Jay Sussman]], via a series of memos now known as the [[Lambda Papers]]. It was the first dialect of Lisp to choose [[Scope (computer science)#Lexical scoping and dynamic scoping|lexical scope]] and the first to require implementations to perform [[tail-call optimization]], giving stronger support for functional programming and associated techniques such as recursive algorithms. It was also one of the first programming languages to support [[First-class object|first-class]] [[continuation]]s. It had a significant influence on the effort that led to the development of [[Common Lisp]].<ref name="cl_steele">Common LISP: The Language, 2nd Ed., Guy L. Steele Jr. Digital Press; 1981. {{ISBN|978-1-55558-041-4}}. "Common Lisp is a new dialect of Lisp, a successor to MacLisp, influenced strongly by ZetaLisp and to some extent by Scheme and InterLisp."</ref>
-->and a ''de facto'' standard called the ''Revised{{padlsup|n}} Report on the Algorithmic Language Scheme'' (R''n''RS).
-->The most recently ratified standard of Scheme<!--
▲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> <!--
--> is "R7RS-small" (2013).<ref name="r7rs">{{Cite 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">{{Cite web |last1=Sperber |first1=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.<!--
▲ -->and a ''de facto'' standard called the ''Revised{{padlsup|n}} Report on the Algorithmic Language Scheme'' (R''n''RS). The most widely implemented standard is R5RS (1998).<ref name="r5rs">{{cite journal |author=Richard Kelsey |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> <!--
-->▼
== History ==
{{
===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">{{
===R6RS===
A new language standardization process began at the 2003 Scheme workshop, with the goal of producing an R6RS standard in 2006. This process broke with the earlier R''n''RS approach of unanimity.
R6RS
Currently the newest releases of various Scheme implementations<ref name="rs6s_Implementations">{{
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>{{Cite journal |last1=Keep |first1=Andrew W. |last2=Dybvig |first2=R. Kent |date=November 2014 |title=A run-time representation of scheme record types |journal=Journal of Functional Programming
R6RS introduces numerous significant changes to the language.<ref name="r6rs_Language_changes">{{
===R7RS===
The R6RS standard has caused controversy because
The ninth draft of R7RS (small language) was made available on April 15, 2013.<ref name="r7rs-draft-9">{{
{{Lisp}}
== Distinguishing features ==
{{
Scheme is primarily a [[functional programming]] language. It shares many characteristics with other members of the Lisp programming language family. Scheme's very simple syntax is based on [[s-expression]]s, parenthesized lists in which a prefix operator is followed by its arguments. Scheme programs thus consist of sequences of nested lists. Lists are also the main data structure in Scheme, leading to a close equivalence between source code and data formats ([[homoiconicity]]). Scheme programs can easily create and evaluate pieces of Scheme code dynamically.
Line 64 ⟶ 63:
The reliance on lists as data structures is shared by all Lisp dialects. Scheme inherits a rich set of [[List (computing)|list-processing]] primitives such as [[Cons|<code>cons</code>]], [[CAR and CDR|<code>car</code> and <code>cdr</code>]] from its Lisp progenitors. Scheme uses strictly but [[Type system|dynamically typed variables]] and supports [[first-class function|first class procedures]]. Thus, procedures can be assigned as values to variables or passed as arguments to procedures.
This section concentrates mainly on innovative features of the language, including those features that distinguish Scheme from other Lisps. Unless stated otherwise, descriptions of features relate to the R5RS standard. In examples provided in this section, the notation "===> result" is used to indicate the result of evaluating the expression on the immediately preceding line. This is the same convention used in R5RS.
{{
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 {{
: '''Fundamental forms''': define, lambda, quote, if, define-syntax, let-syntax, letrec-syntax, syntax-rules, set!
Line 89 ⟶ 83:
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.
{{
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.
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">{{
--><ref name="Moses">{{
{{
[[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.
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>{{Cite
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.
Scheme inherits its block structure from earlier block structured languages, particularly [[ALGOL]].
<syntaxhighlight lang="Scheme">
Line 115 ⟶ 109:
;; Any reference to var here will be bound to "goose"
(let ((var 10))
;; statements go here.
)
;; Any reference to var here will be bound to "goose"
</syntaxhighlight>
Blocks can be [[Nesting (computing)|nested]] to create arbitrarily complex block structures according to the need of the programmer.
One variant of <code>let</code>, <code>let*</code>, permits bindings to refer to variables defined earlier in the same construct, thus:
Line 160 ⟶ 154:
All procedures bound in a single <code>letrec</code> may refer to one another by name, as well as to values of variables defined earlier in the same <code>letrec</code>, but they may not refer to ''values'' defined later in the same <code>letrec</code>.
A variant of <code>let</code>, the "named let" form, has an identifier after the <code>let</code> keyword.
Example: a simple counter
Line 176 ⟶ 170:
Like any procedure in Scheme, the procedure created in the named let is a first-class object.
{{
Scheme has an iteration construct, <code>do</code>, but it is more [[Programming idiom|idiomatic]] in Scheme to use [[tail recursion]] to express [[iteration]]. Standard-conforming Scheme implementations are required to optimize tail calls so as to support an unbounded number of active tail calls (R5RS sec. 3.5)<ref name="r5rs"/>—a property the Scheme report describes as ''proper tail recursion''—making it safe for Scheme programmers to write iterative algorithms using recursive structures, which are sometimes more intuitive. Tail recursive procedures and the ''named <code>let</code>'' form provide support for iteration using tail recursion.
Line 194 ⟶ 188:
</syntaxhighlight>
{{
Continuations in Scheme are [[first-class object]]s.
Continuations can be used to emulate the behavior of [[return statement]]s in imperative programming languages. The following function <code>find-first</code>, given function <code>func</code> and list <code>lst</code>, returns the first element <code>x</code> in <code>lst</code> such that <code>(func x)</code> returns true.
Line 207 ⟶ 201:
(if (func x)
(return-immediately x)))
#f)))
Line 226 ⟶ 220:
</syntaxhighlight>
When executed this code displays a counting sequence: <code>@*@**@***@****@*****@******@*******@********...</code>
<!-- Bear with me, I'm writing a clear English explanation of how this works, but it isn't easy. I'll add it when it's done. -->
▲-->
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.
In Scheme, the same primitives that are used to manipulate and bind data can be used to bind procedures.
<syntaxhighlight lang="Scheme">
Line 260 ⟶ 252:
</syntaxhighlight>
This subsection documents design decisions that have been taken over the years which have given Scheme a particular character, but are not the direct outcomes of the original design.
{{
Scheme specifies a comparatively full set of numerical datatypes including [[complex number|complex]] and [[rational number|rational]] types, which is known in Scheme as the numerical tower (R5RS sec. 6.2<ref name="r5rs"/>).
Numbers may have the quality of exactness.
The R5RS standard specifies procedures <code>exact->inexact</code> and <code>inexact->exact</code> which can be used to change the exactness of a number.
In the R5RS standard, Scheme implementations are not required to implement the whole numerical tower, but they must implement "a coherent subset consistent with both the purposes of the implementation and the spirit of the Scheme language" (R5RS sec. 6.2.3).<ref name="r5rs"/> The new R6RS standard does require implementation of the whole tower, and "exact integer objects and exact rational number objects of practically unlimited size and precision, and to implement certain procedures...so they always return exact results when given exact arguments" (R6RS sec. 3.4, sec. 11.7.1).<ref name="r6rs"/>
Line 305 ⟶ 297:
Both implementations conform to the R5RS standard but the second does not conform to R6RS because it does not implement the full numerical tower.
{{
Scheme supports delayed evaluation through the <code>delay</code> form and the procedure <code>force</code>.
Line 322 ⟶ 314:
===> 22
</syntaxhighlight>
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>.
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">{{
In the R6RS standard, these are no longer primitives, but instead, are provided as part of the R5RS compatibility library (rnrs r5rs (6)).
Line 330 ⟶ 322:
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.
<syntaxhighlight lang="Scheme">
Line 345 ⟶ 337:
</syntaxhighlight>
Most Lisps specify an order of evaluation for procedure arguments.
<syntaxhighlight lang="Scheme">
(let ((ev (lambda(n) (display "Evaluating ")
Line 354 ⟶ 346:
===> 3
</syntaxhighlight>
<syntaxhighlight lang="output">
ev is a procedure that describes the argument passed to it, then returns the value of the argument. In contrast with other Lisps, the appearance of an expression in the operator position (the first item) of a Scheme expression is quite legal, as long as the result of the expression in the operator position is a procedure.▼
In calling the procedure "+" to add 1 and 2, the expressions (ev +), (ev 1) and (ev 2) may be evaluated in any order, as long as the effect is not as if they were evaluated in parallel. Thus the following three lines may be displayed in any order by standard Scheme when the above example code is executed, although the text of one line may not be interleaved with another because that would violate the sequential evaluation constraint.▼
</syntaxhighlight>
▲ev is a procedure that describes the argument passed to it, then returns the value of the argument.
▲In calling the procedure "{{mono|+}}" to add 1 and 2, the expressions {{mono|(ev +), (ev 1)}} and {{mono|(ev 2)}} may be evaluated in any order, as long as the effect is not as if they were evaluated in parallel.
▲: Evaluating 1
▲: Evaluating 2
▲: Evaluating procedure
{{
In the R5RS standard and
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.
<syntaxhighlight lang="Scheme">
Line 377 ⟶ 370:
</syntaxhighlight>
Invocations of macros and procedures bear a close resemblance—both are s-expressions—but they are treated differently.
Most Scheme implementations also provide additional macro systems.
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>{{Cite book |last=Flatt |first=Matthew |title=Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages |
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 reason for this confusion is that in Scheme with its lexical scoping the result of evaluating an expression depends on where it is evaluated.
Retrieved 2012-08-09</ref>
<syntaxhighlight lang="Scheme">
Line 394 ⟶ 387:
</syntaxhighlight>
If it is evaluated in the outer environment, where <code>name</code> is defined, the result is the sum of the 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"
With modern scheme (usually compatible with R5RS) to evaluate this expression,
<syntaxhighlight lang="Scheme">
Line 405 ⟶ 398:
</syntaxhighlight>
<code>interaction-environment</code> is the interpreter's global environment
In most dialects of Lisp including Common Lisp, by convention the value <code>NIL</code> evaluates to the value false in a
Where the constant representing the
In Scheme the primitive datatypes are disjoint.
Within the numerical datatype, by contrast, the numerical values overlap.
{{
Scheme has three different types of equivalence between arbitrary objects denoted by three different ''equivalence predicates'', relational operators for testing equality, <code>eq?</code>, <code>eqv?</code> and <code>equal?</code>:
* <code>eq?</code> evaluates to <code>#f</code> unless its parameters represent the same data object in memory;
Line 426 ⟶ 419:
Type dependent equivalence operations also exist in Scheme: <code>string=?</code> and <code>string-ci=?</code> compare two strings (the latter performs a case-independent comparison); <code>char=?</code> and <code>char-ci=?</code> compare characters; <code>=</code> compares numbers.<ref name="r5rs"/>
{{
Up to the R5RS standard, the standard comment in Scheme was a semicolon, which makes the rest of the line invisible to Scheme.
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>.
The following examples are written in strict R5RS Scheme.
Line 468 ⟶ 461:
</syntaxhighlight>
Similar procedures are provided for input. R5RS Scheme provides the predicates <code>input-port?</code> and <code>output-port?</code>.
In Scheme, procedures are bound to variables.
<syntaxhighlight lang="Scheme">
Line 489 ⟶ 482:
</syntaxhighlight>
In R6RS every binding, including the standard ones, belongs to some library, and all exported bindings are immutable. (R6RS sec 7.1)<ref name="r6rs"/> Because of this, redefinition of standard procedures by mutation is forbidden.
===Nomenclature and naming conventions===
In Standard Scheme, procedures that convert from one datatype to another contain the character string "->" in their name, predicates end with a "?", and procedures that change the value of already-allocated data end with a "!".
In formal contexts such as Scheme standards, the word "procedure" is used in preference to "function" to refer to a lambda expression or primitive procedure.
As in other Lisps, the term "[[thunk]]" is used in Scheme to refer to a procedure with no arguments. The term "proper tail recursion" refers to the property of all Scheme implementations, that they perform tail-call optimization so as to support an indefinite number of active [[tail call]]s.
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">{{
== Review of standard forms and procedures ==
The language is formally defined in the standards R5RS (1998)<ref name="r5rs"/> and R6RS (2007).<ref name="r6rs"/> They describe standard "forms": keywords and accompanying syntax, which provide the control structure of the language, and standard procedures which perform common tasks.▼
▲The language is formally defined in the standards R5RS (1998) and R6RS (2007). They describe standard "forms": keywords and accompanying syntax, which provide the control structure of the language, and standard procedures which perform common tasks.
===Standard forms===
This table describes the standard forms in Scheme.
Forms marked "L" in this table are classed as derived "library" forms in the standard and are often implemented as macros using more fundamental forms in practice, making the task of implementation much easier than in other languages.
Line 513 ⟶ 504:
{| class="wikitable"
|+ Standard forms in the language R5RS Scheme
! Purpose
|-
| Definition || {{mono|define}}
|-
| Binding constructs || {{mono|lambda, do (L), let (L), let* (L), letrec (L)}}
|-
| Conditional evaluation || {{mono|if, cond (L), case (L), and (L), or (L)}}
|-
| Sequential evaluation || {{mono|begin (*)}}
|-
| Iteration || {{mono|lambda, do (L), named let (L)}}
|-
| Syntactic extension || {{mono|define-syntax, let-syntax, letrec-syntax, syntax-rules (R5RS), syntax-case (R6RS)}}
|-
| Quoting || {{mono|quote('), unquote(,), quasiquote(`), unquote-splicing(,@)}}
|-
| Assignment || {{mono|set!}}
|-
| Delayed evaluation || {{mono|delay (L)}}
|}
===Standard procedures===
Line 544 ⟶ 535:
! Purpose !! Procedures
|-
| Construction || {{mono|vector, make-vector, make-string, list}}
|-
| Equivalence predicates || {{mono|1=eq?, eqv?, equal?, string=?, string-ci=?, char=?, char-ci=?}}
|-
| [[Type conversion]] || {{mono|vector->list, list->vector, number->string, string->number, symbol->string, string->symbol, char->integer, integer->char, string->list, list->string}}
|-
| Numbers || {{mono|''See separate table''}}
|-
| Strings || {{mono|1=string?, make-string, string, string-length, string-ref, string-set!, string=?, string-ci=?, string<? string-ci<?, string<=? string-ci<=?, string>? string-ci>?, string>=? string-ci>=?, substring, string-append, string->list, list->string, string-copy, string-fill!}}
|-
| Characters || {{mono|1=char?, char=?, char-ci=?, char<? char-ci<?, char<=? char-ci<=?, char>? char-ci>?, char>=? char-ci>=?, char-alphabetic?, char-numeric?, char-whitespace?, char-upper-case?, char-lower-case?, char->integer, integer->char, char-upcase, char-downcase}}
|-
| Vectors || {{mono|make-vector, vector, vector?, vector-length, vector-ref, vector-set!, vector->list, list->vector, vector-fill!}}
|-
| Symbols || {{mono|symbol->string, string->symbol, symbol?}}
|-
| Pairs and lists || {{mono|pair?, cons, car, cdr, set-car!, set-cdr!, null?, list?, list, length, append, reverse, list-tail, list-ref, memq. memv. member, assq, assv, assoc, list->vector, vector->list, list->string, string->list}}
|-
| Identity predicates || {{mono|boolean?, pair?, symbol?, number?, char?, string?, vector?, port?, procedure?}}
|-
| Continuations || {{mono|call-with-current-continuation (call/cc), values, call-with-values, dynamic-wind}}
|-
| Environments || {{mono|eval, scheme-report-environment, null-environment, interaction-environment (optional)}}
|-
| Input/output || {{mono|display, newline, read, write, read-char, write-char, peek-char, char-ready?, eof-object? open-input-file, open-output-file, close-input-port, close-output-port, input-port?, output-port?, current-input-port, current-output-port, call-with-input-file, call-with-output-file, with-input-from-file(optional), with-output-to-file(optional)}}
|-
| System interface || {{mono|load (optional), transcript-on (optional), transcript-off (optional)}}
|-
| Delayed evaluation || {{mono|force}}
|-
| Functional programming || {{mono|procedure?, apply, map, for-each}}
|-
| Booleans || {{mono|boolean? not}}
|}
Line 585 ⟶ 576:
! Purpose !! Procedures
|-
| Basic arithmetic operators || {{mono|+, -, *, /, abs, quotient, remainder, modulo, gcd, lcm, expt, sqrt}}
|-
| Rational numbers || {{mono|numerator, denominator, rational?, rationalize}}
|-
| Approximation || {{mono|floor, ceiling, truncate, round}}
|-
| Exactness || {{mono|inexact->exact, exact->inexact, exact?, inexact?}}
|-
| Inequalities || {{mono|1=<, <= , >, >=, =}}
|-
| Miscellaneous predicates || {{mono|zero?, negative?, positive? odd? even?}}
|-
| Maximum and minimum || {{mono|max, min}}
|-
| Trigonometry || {{mono|sin, cos, tan, asin, acos, atan}}
|-
| Exponentials || {{mono|exp, log}}
|-
| Complex numbers || {{mono|make-rectangular, make-polar, real-part, imag-part, magnitude, angle, complex?}}
|-
| Input-output || {{mono|number->string, string->number}}
|-
| Type predicates || {{mono|integer?, rational?, real?, complex?, number?}}
|}
Line 613 ⟶ 604:
== Scheme Requests for Implementation ==
{{
Because of Scheme's minimalism, many common procedures and syntactic forms are not defined by the standard.
SRFIs with fairly wide support in different implementations include:<ref name="srfi_support">{{
* 0: feature-based conditional expansion construct
Line 649 ⟶ 640:
== 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]].
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
Some implementations support
== Usage ==
Scheme is widely used by
The textbook ''[[How to Design Programs]]''
The former introductory
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">{{
* 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 {{
* [[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">{{
* [[Extension Language Kit|Elk Scheme]] is used by [[Synopsys]] as a scripting language for its [[Technology CAD|technology CAD (TCAD)]] tools.<ref name="tcad">{{
* 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">{{
* [[Google App Inventor]] for [[Android (operating system)|Android]] uses Scheme, where [[Kawa (Scheme implementation)|Kawa]] is used to compile the Scheme code down to
== See also ==
{{
*''[[Essentials of Programming Languages]]'',
▲*''[[Essentials of Programming Languages]]'', another classic [[computer science]] textbook.
== References ==
Line 682 ⟶ 671:
== Further reading ==
* [https://web.archive.org/web/20220313232321/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])
* {{
* {{
*
== External links ==
*[https://scheme.org/ scheme.org] provides links to many Scheme resources, including the specifications
*{{Wikibooks
*[https://lips.js.org/docs/category/introduction-to-scheme Introduction to Scheme]
*{{Wikibooks
*{{Commons category-inline|Scheme (programming language)}}
*[https://discu.eu/weekly/lisp/ Scheme Weekly]
*[https://lips.js.org/#bookmark Bookmarklet that add Interactive Scheme REPL to any website]
{{Authority control}}
<!--Eponymous categories:-->
|