commit 20217f1286781478293c21d1166de93ff3e37fcb
parent 031547d3a0f414afc64ba066701e1829073e6995
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date: Wed, 31 Jan 2024 14:07:03 -0500
Procedures: Texify.
Diffstat:
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/doc/r7rs-small/r7rs-small.texinfo b/doc/r7rs-small/r7rs-small.texinfo
@@ -1322,29 +1322,28 @@ to itself. In Scheme, it is an error.
@node Procedures
@subsection Procedures
-syntax: (lambda @svar{formals} @svar{body})
+@deffn syntax lambda @svar{formals} @svar{body}
Syntax: @svar{Formals} is a formal arguments list as described below, and @svar{body} is a sequence
of zero or more definitions followed by one or more expressions.
-Semantics: A lambda expression evaluates to a procedure. The environment in effect when
-the lambda expression was evaluated is remembered as part of the procedure. When the
+Semantics: A @code{lambda} expression evaluates to a procedure. The environment in effect when
+the @code{lambda} expression was evaluated is remembered as part of the procedure. When the
procedure is later called with some actual arguments, the environment in which the
-lambda expression was evaluated will be extended by binding the variables in the formal
+@code{lambda} expression was evaluated will be extended by binding the variables in the formal
argument list to fresh locations, and the corresponding actual argument values will be
-stored in those locations. (A fresh location is one that is distinct from every previously
-existing location.) Next, the expressions in the body of the lambda expression (which, if it
-contains definitions, represents a letrec* form---see section 4.2.2) will be evaluated
+stored in those locations. (A @dfn{fresh} location is one that is distinct from every previously
+existing location.) Next, the expressions in the body of the @code{lambda} expression (which, if it
+contains definitions, represents a @code{letrec*} form---@xref{Binding constructs}) will be evaluated
sequentially in the extended environment. The results of the last expression in the body
will be returned as the results of the procedure call.
-@c TODO: "a procedure" should not appear in typewriter font. The
-@c same goes for "unspecified" results throughout the file.
-@example
-
-(lambda (x) (+ x x)) @result{} a procedure
-((lambda (x) (+ x x)) 4) @result{} 8
+@display
+@code{((lambda (x) (+ x x))} @result{} a procedure
+@code{((lambda (x) (+ x x)) 4)} @result{} @code{8}
+@end display
+@example
(define reverse-subtract
(lambda (x y) (- y x)))
(reverse-subtract 7 10) @result{} 3
@@ -1360,7 +1359,7 @@ will be returned as the results of the procedure call.
@itemize
@item
-(@svar{variable1} @dots{}): The procedure takes a fixed number of arguments; when the
+@code{(}@svar{variable@sub{1}} @dots{}@code{)}: The procedure takes a fixed number of arguments; when the
procedure is called, the arguments will be stored in fresh locations that are bound to
the corresponding variables.
@@ -1370,8 +1369,8 @@ called, the sequence of actual arguments is converted into a newly allocated lis
the list is stored in a fresh location that is bound to @svar{variable}.
@item
-(@svar{variable1} @dots{} @svar{variablen} . @svar{variablen+1}): If a space-delimited period precedes the last
-variable, then the procedure takes n or more arguments, where n is the number of
+@code{(}@svar{variable@sub{1}} @dots{} @svar{variable@sub{n}} . @svar{variable@sub{n+1}}@code{)}: If a space-delimited period precedes the last
+variable, then the procedure takes @var{n} or more arguments, where @var{n} is the number of
formal arguments before the period (it is an error if there is not at least one). The value
stored in the binding of the last variable will be a newly allocated list of the actual
arguments left over after all the other actual arguments have been matched up against
@@ -1389,9 +1388,9 @@ It is an error for a @svar{variable} to appear more than once in @svar{formals}.
@end example
-Each procedure created as the result of evaluating a lambda expression is (conceptually)
-tagged with a storage location, in order to make eqv? and eq? work on procedures (see
-section 6.1).
+Each procedure created as the result of evaluating a @code{lambda} expression is (conceptually)
+tagged with a storage location, in order to make @code{eqv?} and @code{eq?} work on procedures
+(@xref{Equivalence predicates}).
@node Conditionals (if)
@subsection Conditionals (if)