[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
COND/DO consistency
Consider: [paraphrase of 4.2.1]
| (COND (<test> <expression>...)
| (<test> <expression>...)
| ...
| (ELSE <expression> <expression>...))
|
| For the first <test> that evaluates to a true value, the value of
| the last <expression> in that clause is returned as the result of the
| COND. If that clause contains only a <test> and no <expression>s,
| then the value of the <test> is returned as the result.
Compare with: [paraphrase of 4.2.4]
| (DO ((<variable> <init> <step>)
| ...)
| (<test> <expression>...)
| <command>...)
|
| If the <test> evaluates to a true value, then the value of the last
| <expression> is returned as the result of the DO. If no <expression>s
| are present, then the value of the DO expression is unspecified.
I propose that this last line read "then the value of the <test> is
returned as the value of the DO expression." for consistency with the
way test clauses are handled in COND.
Consequently, I propose that the rewrite rule for DO in section 7.3
be changed to:
| (DO ((<variable_1> <init_1> <step_1>)
| ...)
| (<test> <expression>...) ;; NB: <sequence> changed to <expr>...
| <command_1>...)
|
| = (LETREC ((<loop>
| (LAMBDA (<variable_1>...)
| (COND (<test> <expression>...) ;; NB: COND
| (ELSE <command_1> ;; not IF
| ... ;;
| (<loop> <step_1>...)))))) ;;
| (<loop> <init_1>...))
This is a virtually effortless change which enhances the regularity
of the language.
~Ziggy