Commandments
Table of Contents
- 1. 11 - The Eleventh Commandment - Accumulation of results or maintaining state
- 2. 12 - The Twelfth Commandment - Avoiding of unchanging iteration arguments
- 3. 13 - The Thirteenth Commandment - Usage of
(letrec ...)
or namedlet
or inner(define ...)
- 4. 14 - The Fourteenth Commandment - Usage of
(call-with-current-continuation ...)
- 5. 15 - The Fifteenth Commandment - Usage of
(let ...)
1. 11 - The Eleventh Commandment - Accumulation of results or maintaining state
Use additional arguments when a function needs to know what other arguments to the function have been like so far.
2. 12 - The Twelfth Commandment - Avoiding of unchanging iteration arguments
Use
(letrec ...)
to remove arguments that do not change for recursive application.
However, in some Scheme dialects one can also use define
in all or most contexts (definition contexts), so that one does not need to use letrec
.
3. 13 - The Thirteenth Commandment - Usage of (letrec ...)
or named let
or inner (define ...)
Use
(letrec ...)
to hide and to protect functions.
4. 14 - The Fourteenth Commandment - Usage of (call-with-current-continuation ...)
Use
(letcc ...)
to return values abruptly and promptly.
However, in Scheme dialects, it is called (call-with-current-continuation ...)
instead. One could write a macro transforming it into (letrec ...)
though.
5. 15 - The Fifteenth Commandment - Usage of (let ...)
Use (let ...)
to name the values of repeated expressions in a function definition if they may be evaluated twice for one and the same use of the function.