letrec* -- r7rs Definition syntax;
Syntax keywords:
variable: identifier;initializer: identifier;binding: pattern with variants:
(variable initializer);bindings: pattern with variants:
();(binding |...|);expression: expression;Syntax variants:
(_ bindings)(_ bindings expression |...|)scheme:base -- (scheme base);scheme -- (scheme);(letrec* <bindings> <body>)Syntax:
<Bindings>has the form((<variable_1> <init_1>) ...)and
<body>is a sequence of zero or more definitions followed by one or more expressions as described in section onlambda. It is an error for a<variable>to appear more than once in the list of variables being bound.Semantics: The
<variable>s are bound to fresh locations, each<variable>is assigned in left-to-right order to the result of evaluating the corresponding<init>, the<body>is evaluated in the resulting environment, and the values of the last expression in<body>are returned. Despite the left-to-right evaluation and assignment order, each binding of a<variable>has the entireletrec*expression as its region, making it possible to define mutually recursive procedures.If it is not possible to evaluate each
<init>without assigning or referring to the value of the corresponding<variable>or the<variable>of any of the bindings that follow it in<bindings>, it is an error. Another restriction is that it is an error to invoke the continuation of an<init>more than once.(letrec* ((p (lambda (x) (+ 1 (q (- x 1))))) (q (lambda (y) (if (zero? y) 0 (+ 1 (p (- y 1)))))) (x (p 5)) (y x)) y) ===> 5
The text herein was sourced and adapted as described in the "R7RS attribution of various text snippets" appendix.