语言为#lang web-server/insta
,此代码将在传递给response/xexpr
-> (define home 'home-page)
-> (make-navigation home "home-page")
注意((href , (embed/url ...
之前的`backquote
'(p ((id "home-page")) (a `((href ,(embed/url home-page))) "home-page"))
请注意,`已经消失了。
'(p ((id "home-page")) (a ((href ,(embed/url home-page))) "home-page"))
(define (make-navigation uri label)
(define (make-id uri)
`((id ,(symbol->string uri))))
(define-syntax-rule (embed uri)
``((href ,(embed/url ,uri))))
`(p ,(make-id uri)
(a ,(embed uri)
,label)))
问题可能出在embed
。
答案 0 :(得分:1)
#lang racket
(define (make-navigation uri label)
(define (make-id uri)
`((id ,(symbol->string uri))))
(define-syntax-rule (embed uri)
'((href ,(embed/url uri))))
`(p ,(make-id uri)
(a ,(embed uri)
,label)))
(define home 'home-page)
(make-navigation home "home-page")
输出:
'(p ((id "home-page")) (a ((href ,(embed/url uri))) "home-page"))
更新
(define (make-navigation uri label)
(define (make-id uri)
`((id ,(symbol->string uri))))
(define-syntax-rule (embed uri)
`((href ,(list 'unquote (list 'embed/url uri)))))
`(p ,(make-id uri)
(a ,(embed uri)
,label)))
(define home 'home-page)
(make-navigation home "home-page")
输出:
'(p ((id "home-page")) (a ((href ,(embed/url home-page))) "home-page"))