From 7fe6a5007c8034c7716317415873084f492a2b76 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 10 Dec 2013 08:11:54 -0800 Subject: [PATCH] separate functions and syntaces related to multiple value --- piclib/built-in.scm | 47 +++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index f59e1887..23af2bbc 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -254,8 +254,32 @@ do when unless _ ... syntax-error)) + +;;; multiple value +(define-library (picrin multiple-value) + (import (scheme base) + (picrin macro) + (picrin core-syntax)) + + (define (values . args) + (if (and (pair? args) + (null? (cdr args))) + (car args) + (cons '*values-tag* args))) + + (define (call-with-values producer consumer) + (let ((res (producer))) + (if (and (pair? res) + (eq? '*values-tag* (car res))) + (apply consumer (cdr res)) + (consumer res)))) + + (export values + call-with-values)) + (import (picrin macro) - (picrin core-syntax)) + (picrin core-syntax) + (picrin multiple-value)) (export let let* letrec letrec* quasiquote unquote unquote-splicing @@ -264,6 +288,9 @@ do when unless _ ... syntax-error) +(export values + call-with-values) + (define (any pred list) (if (null? list) #f @@ -288,24 +315,6 @@ ;;; FIXME forward declaration (define map #f) -;;; multiple value - -(define (values . args) - (if (and (pair? args) - (null? (cdr args))) - (car args) - (cons '*values-tag* args))) - -(define (call-with-values producer consumer) - (let ((res (producer))) - (if (and (pair? res) - (eq? '*values-tag* (car res))) - (apply consumer (cdr res)) - (consumer res)))) - -(export values - call-with-values) - ;;; 6.2. Numbers (define (zero? n)