From 4383801e6e05d2b5b3a3dcf274e410e2f42ce8b8 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 8 Jul 2019 15:34:09 -0400 Subject: [PATCH] Change multiple-value return to be slighly closer to correct. It's never going to be correct, but this at least permits mixing single values and multiple values a bit. --- src/runtime/global.scm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/runtime/global.scm b/src/runtime/global.scm index ba9a00374..e9a6675d4 100644 --- a/src/runtime/global.scm +++ b/src/runtime/global.scm @@ -129,12 +129,22 @@ USA. (define bind-cell-contents! (object-component-binder cell-contents set-cell-contents!)) +(define-record-type + (make-multi-values list) + multi-values? + (list multi-values-list)) + (define (values . objects) - (lambda (receiver) - (apply receiver objects))) + (if (and (pair? objects) + (null? (cdr objects))) + (car objects) + (make-multi-values objects))) (define (call-with-values thunk receiver) - ((thunk) receiver)) + (let ((v (thunk))) + (if (multi-values? v) + (apply receiver (multi-values-list v)) + (receiver v)))) (define (write-to-string object #!optional max) (if (or (default-object? max) (not max)) -- 2.25.1