separate functions and syntaces related to multiple value

This commit is contained in:
Yuichi Nishiwaki 2013-12-10 08:11:54 -08:00
parent 12aff8134f
commit 7fe6a5007c
1 changed files with 28 additions and 19 deletions

View File

@ -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)