From 2afa667772a04493599f2e7361ea1bf7d14bd877 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 9f6f4f779..8297620b8 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