良い名前が思い浮かびませんでした。当初 lump-init-let としていましたが、長いのでボツ。(let-with init-value ... というような意味合いを込めて、let/ ・・・。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; let/ | |
(define-syntax let/ | |
(syntax-rules () | |
((_ val (var ...) body ...) | |
(let ((var val) ...) | |
body ...)) | |
((_ (var ...) body ...) | |
(let/ #f (var ...) body ...)))) | |
(let/ '() (a b c d e) | |
(for-each print | |
(list a b c d))) | |
;; () | |
;; () | |
;; () | |
;; () | |
;; #<undef> | |
(let/ (a b c d) | |
(for-each print | |
(list a b c d))) | |
; -> *** ERROR: unbound variable: b | |
(macroexpand '(let/ (a b c d) | |
(for-each print | |
(list a b c d)))) | |
;; (#<identifier user#let> | |
;; ((for-each #0=(a b c d)) | |
;; (print #0#) ((list a b c d) #0#))) | |
(define-syntax let/ | |
(syntax-rules () | |
((_ val (var ...) body ...) | |
(let ((var val) ...) | |
body ...)))) | |
(let/ ((lambda () | |
(print "hoge") | |
#f)) | |
(a b c d) | |
(for-each print (list a b c d))) | |
;; hoge | |
;; hoge | |
;; hoge | |
;; hoge | |
;; #f | |
;; #f | |
;; #f | |
;; #f | |
;; #<undef> | |
(define-syntax let/ | |
(syntax-rules () | |
((_ val (var ...) body ...) | |
(let ((v val)) | |
(let ((var v) ...) | |
body ...))))) | |
(let/ ((lambda () | |
(print "hoge") | |
#f)) | |
(a b c d) | |
(for-each print (list a b c d))) | |
;; hoge | |
;; #f | |
;; #f | |
;; #f | |
;; #f | |
;; #<undef> |
0 件のコメント:
コメントを投稿