Re: [Scheme-reports] 5. Program Structure
Andy Wingo 07 Jan 2013 11:48 UTC
Hi,
I don't have much more to say about the r7rs, but there is this one
point.
On Sun 06 Jan 2013 02:53, Alex Shinn <alexshinn@gmail.com> writes:
> Also it's not true, unfortunately! Because in the next section,
> "5.3.3
> Multiple-value definitions", we see the introduction of
> `define-values'
> with an optimistically short specification and no corresponding
> expansion.
>
> Define-values is just derived syntax, it doesn't need special
> treatment.
Ah, I hadn't seen the expansion in the appendix. It does seem to be
broken, though; var0 will hold the list of values, not the first value.
How about this expansion:
(define-syntax define-values
(syntax-rules ()
((_ (var ... . var*) expr)
(begin
(define values
(call-with-values (lambda () expr) list))
(define var
(let ((x (car values)))
(set! values (cdr values))
x))
...
(define var* values)))
((_ (var ...) expr)
(begin
(define values
(call-with-values (lambda () expr) list))
(define var
(let ((x (car values)))
(set! values (cdr values))
x))
...))))
No error checking though.
Also, if used at the top-level, the above and the report expansion may
or may not bind an unrenamed variable ("dummy" or "values"), depending
on the implementation. Not so great.
> I think you _cannot_ introduce define-values without
> `letrec-values' and `letrec*-values' and corresponding semantics
>
> I disagree. I'd love to remove all three though.
To be clear, neither letrec-values nor letrec*-values are present in the
report. Thus there is nothing to remove, there.
I still think that define-values should be accompanied with
letrec-values / letrec*-values or not present at all, but given that you
have an expansion this is not as crucial.
Andy
--
http://wingolog.org/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports