export destructuring-bind

This commit is contained in:
Yuichi Nishiwaki 2014-08-06 03:05:18 +09:00
parent 5a3443a881
commit 1a7df924ab
1 changed files with 6 additions and 5 deletions

View File

@ -2,7 +2,7 @@
(import (scheme base) (import (scheme base)
(picrin macro)) (picrin macro))
(define-syntax bind (define-syntax destructuring-bind
(ir-macro-transformer (ir-macro-transformer
(lambda (form inject compare) (lambda (form inject compare)
(let ((formal (car (cdr form))) (let ((formal (car (cdr form)))
@ -14,8 +14,8 @@
,@body)) ,@body))
((pair? formal) ((pair? formal)
`(let ((value# ,value)) `(let ((value# ,value))
(bind ,(car formal) (car value#) (destructuring-bind ,(car formal) (car value#)
(bind ,(cdr formal) (cdr value#) (destructuring-bind ,(cdr formal) (cdr value#)
,@body)))) ,@body))))
((vector? formal) ((vector? formal)
;; TODO ;; TODO
@ -31,7 +31,7 @@
(lambda (form inject compare) (lambda (form inject compare)
(let ((args (car (cdr form))) (let ((args (car (cdr form)))
(body (cdr (cdr form)))) (body (cdr (cdr form))))
`(lambda formal# (bind ,args formal# ,@body)))))) `(lambda formal# (destructuring-bind ,args formal# ,@body))))))
(define-syntax destructuring-define (define-syntax destructuring-define
(ir-macro-transformer (ir-macro-transformer
@ -43,5 +43,6 @@
(destructuring-lambda ,(cdr maybe-formal) (destructuring-lambda ,(cdr maybe-formal)
,@(cddr form)))))))) ,@(cddr form))))))))
(export (rename destructuring-lambda lambda) (export (rename destructuring-bind bind)
(rename destructuring-lambda lambda)
(rename destructuring-define define))) (rename destructuring-define define)))