separate functions and syntaces related to multiple value
This commit is contained in:
parent
12aff8134f
commit
7fe6a5007c
|
@ -254,9 +254,33 @@
|
|||
do when unless
|
||||
_ ... syntax-error))
|
||||
|
||||
(import (picrin macro)
|
||||
|
||||
;;; 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 multiple-value))
|
||||
|
||||
(export let let* letrec letrec*
|
||||
quasiquote unquote unquote-splicing
|
||||
and or
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue