I'm trying to grok the formal semantics section, 7.2, of r7rs small.
It seems to me there are numerous small errors, but perhaps I'm just confused.
I don't see any errata for the formal section on the web page; and I couldn't find a better place to submit bugs....so, here goes:
;;;;
;; car-internal
;;;;
As written, the declared type of car-internal is "_expression_-value to
_expression_-continuation to command-continuation" (E->K->C).
However, the definition starts with "lambda ewk", and results in calling hold on two
args (and that results in a command-continuation). So the type of the
definition is "_expression_-value to dynamic-point to _expression_-continuation
to command-continuation" (E->P->K->C).
Based on how car-internal is called, the fix appears to be: simply delete
the w in the definition (that is, delete the \omega). In other words, the
type statement is correct, but the definition is not.
;;;;
;; valueslist
;;;;
As-is the definition of valueslist resembles:
;; E->K->C
(define valueslist
(lambda (e k)
(if (pair? e)
(cdr-internal e
(lambda (e*) ; (0)
(valueslist e* ; (1)
(lambda (e**)
(car-internal e
(single (lambda (e+) ; (2)
(k (list* e+ e**)))) ; (3) list*=cons
))
))
)
;; not a pair
(if (null? e) (k (list)) (error "non-list argument to
*values-list*"))
)))
At (1), e* will be a (singleton) sequence of values, but values-list does
not accept a sequence of values as its first argument. Since car-internal
and cdr-internal work by sending a singleton sequence to their
_expression_-continuation, it seems that (1) should be:
(valueslist (first e*) ...) ; (A)
Alternatively, (0) could be:
(single (lambda (e++) (valueslist e++ ...)) ; (B)
That is perhaps more pleasing, since it would be symmetric with how
car-internal is called at (2).
On the other-hand, calling internal functions (bypassing type-checks)
suggests complete confidence, and so perhaps bypassing
argument-count checking (from single) is desirable as well. If so,
then (A) is preferable, and for symmetry, likewise (2) should be:
(lambda (e***) (k (list (first e***) e**) )) ; (A')
Incidentally, list->values seems more Scheme-y than valueslist.
_______________________________________________ Scheme-reports mailing list Scheme-reports@x http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports