| :-D Closures indeed! A key concept of Scheme that distinguished it from most Lisps at the time: (LAMBDA ( <identifier list> ) <body> ) Lambda-expressions evaluate to procedures. Unlike most LISP systems, SCHEME does not consider a lambda-expression (an s-expression whose car is the atom LAMBDA) to be a procedure. A lambda-expression only evaluates to a procedure. A lambda-expression should be thought of as a partial description of a procedure; a procedure and a description of it are conceptually distinct objects. A lambda-expression must be “closed” (associated with an environment) to produce a procedure object. Evaluation of a lambda-expression performs such a closure operation. The resulting procedure takes as many arguments as there are identifiers in the identifier list of the lambda-expression. When the procedure is eventually invoked, the intuitive effect is that the evaluation of the procedure call is equivalent to the evaluation of the <body> in an environment consisting of (a) the environment in which the lambda-expression had been evaluated to produce the procedure, plus (b) the pairing of the identifiers of the <identifier list> with the arguments supplied to the procedure. The pairings (b) take precedence over the environment (a), and to prevent confusion no identifier may appear twice in the <identifier list>. The net effect is to implement ALGOL-style lexical scoping [Naur], and to “solve the funarg problem” [Moses]. THE REVISED REPORT ON SCHEME: A DIALECT OF LISP B.1. Kernel Magic Forms https://research.scheme.org/lambda-papers/lambda-papers-revi... Moar: 3.2 The Environment Model of Evaluation https://sarabander.github.io/sicp/html/3_002e2.xhtml#g_t3_00... |