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