Simplify macro
This commit is contained in:
parent
8681daf54a
commit
d1bc934f9c
1 changed files with 15 additions and 9 deletions
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
(define-syntax define-view
|
(define-syntax define-view
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(syntax-case x ()
|
(syntax-case x (where)
|
||||||
((_ name doc fmt fields fields* ...)
|
((_ name doc fmt fields fields* ... where predicate)
|
||||||
(with-syntax ((viewname
|
(with-syntax ((viewname
|
||||||
(datum->syntax
|
(datum->syntax
|
||||||
x (symbol-append (syntax->datum #'name) '-view))))
|
x (symbol-append (syntax->datum #'name) '-view))))
|
||||||
|
@ -17,14 +17,20 @@
|
||||||
(let (#,@(map (lambda (field)
|
(let (#,@(map (lambda (field)
|
||||||
#`(#,field (cdr (assq (quote #,field) item))))
|
#`(#,field (cdr (assq (quote #,field) item))))
|
||||||
#'(fields fields* ...)))
|
#'(fields fields* ...)))
|
||||||
|
(if predicate
|
||||||
(format #t fmt
|
(format #t fmt
|
||||||
#,@(map (lambda (field)
|
#,@(map (lambda (field)
|
||||||
field)
|
field)
|
||||||
#'(fields fields* ...)))))
|
#'(fields fields* ...))))))
|
||||||
todo-list))
|
todo-list))
|
||||||
(set! view-list
|
(set! view-list
|
||||||
(append view-list
|
(append view-list
|
||||||
(list (cons 'name viewname))))))))))
|
(list (cons 'name viewname)))))))
|
||||||
|
((_ name doc fmt fields fields* ...)
|
||||||
|
(with-syntax ((viewname
|
||||||
|
(datum->syntax
|
||||||
|
x (symbol-append (syntax->datum #'name) '-view))))
|
||||||
|
#'(define-view name doc fmt fields fields* ... where #t))))))
|
||||||
|
|
||||||
(define todo-list-file "todo.scm")
|
(define todo-list-file "todo.scm")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue