move experimental/lambda.scm

This commit is contained in:
Yuichi Nishiwaki 2015-07-09 02:18:56 +09:00
parent c76690c4da
commit 685d08301a
4 changed files with 25 additions and 38 deletions

View File

@ -9,7 +9,6 @@ PICRIN_OBJS = \
$(PICRIN_SRCS:.c=.o)
PICRIN_LIBS = \
piclib/picrin/macro.scm\
piclib/picrin/experimental/lambda.scm\
piclib/picrin/syntax-rules.scm\
piclib/picrin/test.scm

View File

@ -0,0 +1,24 @@
(define-library (picrin destructuring-bind)
(import (picrin base)
(picrin macro))
(define-syntax (destructuring-bind formal value . body)
(cond
((variable? formal)
#`(let ((#,formal #,value))
#,@body))
((pair? formal)
#`(let ((value #,value))
(destructuring-bind #,(car formal) (car value)
(destructuring-bind #,(cdr formal) (cdr value)
#,@body))))
((vector? formal)
;; TODO
(error "fixme"))
(else
#`(if (equal? #,value '#,formal)
(begin
#,@body)
(error "match failure" #,value '#,formal)))))
(export destructuring-bind))

View File

@ -0,0 +1 @@
CONTRIB_LIBS += $(wildcard contrib/50.destructuring-bind/*.scm)

View File

@ -1,37 +0,0 @@
(define-library (picrin experimental lambda)
(import (picrin base)
(picrin macro))
(define-syntax (destructuring-let formal value . body)
(cond
((variable? formal)
#`(let ((#,formal #,value))
#,@body))
((pair? formal)
#`(let ((value #,value))
(destructuring-let #,(car formal) (car value)
(destructuring-let #,(cdr formal) (cdr value)
#,@body))))
((vector? formal)
;; TODO
(error "fixme"))
(else
#`(if (equal? #,value '#,formal)
(begin
#,@body)
(error "match failure" #,value '#,formal)))))
(define-syntax (destructuring-lambda formal . body)
#`(lambda args
(destructuring-let #,formal args #,@body)))
(define-syntax (destructuring-define formal . body)
(if (variable? formal)
#`(define #,formal #,@body)
#`(destructuring-define #,(car formal)
(destructuring-lambda #,(cdr formal)
#,@body))))
(export (rename destructuring-let let)
(rename destructuring-lambda lambda)
(rename destructuring-define define)))