|
|
|
@ -10,7 +10,7 @@
|
|
|
|
|
(car result)
|
|
|
|
|
result)))
|
|
|
|
|
|
|
|
|
|
(define-syntax format-datum
|
|
|
|
|
#;(define-syntax format-datum
|
|
|
|
|
(λ(stx)
|
|
|
|
|
(syntax-case stx (quote datum)
|
|
|
|
|
[(_ (quote <datum-template>) <arg> ...)
|
|
|
|
@ -21,14 +21,19 @@
|
|
|
|
|
(syntax->datum arg)
|
|
|
|
|
arg)) (list <arg> ...)))))])))
|
|
|
|
|
|
|
|
|
|
(define (format-datum datum-template . args)
|
|
|
|
|
(string->datum (apply format (format "~a" datum-template) (map (λ(arg) (if (syntax? arg)
|
|
|
|
|
(syntax->datum arg)
|
|
|
|
|
arg)) args))))
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
|
(require rackunit)
|
|
|
|
|
(require rackunit syntax/datum)
|
|
|
|
|
(check-equal? (string->datum "foo") 'foo)
|
|
|
|
|
(check-equal? (string->datum "(foo bar)") '(foo bar))
|
|
|
|
|
(check-equal? (string->datum "foo bar") '(foo bar))
|
|
|
|
|
(check-equal? (string->datum "42") 42)
|
|
|
|
|
(check-equal? (format-datum '(~a-bar-~a) "foo" "zam") '(foo-bar-zam))
|
|
|
|
|
(check-equal? (format-datum '(~a-bar-~a) #'foo #'zam) '(foo-bar-zam))
|
|
|
|
|
(check-equal? (format-datum (datum (~a-bar-~a)) "foo" "zam") '(foo-bar-zam))
|
|
|
|
|
(check-equal? (format-datum '~a "foo") 'foo)
|
|
|
|
|
(check-equal? (format-datum (datum ~a) "foo") 'foo))
|
|
|
|
|