[R7RS] Why is letrec[*]-values missing from the report?

27 views
Skip to first unread message

Arthur A. Gleckler

unread,
Feb 11, 2016, 7:46:32 PM2/11/16
to scheme-reports-wg1
Here's another message from Marc Nieper-Wißkirchen (on
<comp.lang.scheme>):

From: Marc Nieper-Wißkirchen <marc....@gmail.com>
Subject: [R7RS] Why is letrec[*]-values missing from the report?
Newsgroups: comp.lang.scheme
Date: Thu, 11 Feb 2016 05:35:17 -0800 (PST)

The report defines the binding constructs 'let', 'let*', 'letrec', 'letrec*',
'let-values', and 'let*-values'. This is not a complete orthogonal set of binding constructs with 'letrec-values' and 'letrec*-values' missing.

Of course, it is easy to implement 'letrec*-values' on top of R7RS, e.g. by transforming '(letrec-values (<binding> ...) . <body>)' into '(let () (define-values <binding>) ... (let () . <body>)' due to the way internal defines work.

Maybe from the point of you of an implementer, in 5.3.2 of the report the relation is stated the other way round: Internal defines can always be converted into a completely equivalent 'letrec*' expression. In order to convert 'define-values', a conversion into the hypothetical 'letrec*-values' is straight-forward. A conversion into 'letrec*' will, however, lead most likely to suboptimal code as in

(letrec* ((%dummy (call-with-values
(lambda () (values 1 2 3))
(lambda (values)
(apply vector values))))
(a (vector-ref %dummy 0))
(b (vector-ref %dummy 1))
(c (vector-ref %dummy 2)))
.
<body>)

versus

(letrec*-values (((a b c) (values 1 2 3)))
.
<body>)

Thus, I am wondering what the rationale was to omit 'letrec[*]-values' from the report, when every implementation has to provide via internal defines anyway?
Reply all
Reply to author
Forward
0 new messages