Arbitrary computation in Scheme macro

隐身守侯 提交于 2019-12-04 16:00:17

Yes, the fact that you're using Racket matters -- in Racket, there is something that is called "phase separation", which means that the syntax level cannot use runtime functions. For example, this:

#lang racket
(define (bleh) #'123)
(define-syntax (foo stx)
  (bleh))
(foo)

will not work since bleh is bound at a runtime, not available for syntax. Instead, it should be

(define-for-syntax (bleh) #'123)

or

(begin-for-syntax (define (bleh) #'123))

or moved as an internal definition to the macro body, or moved to its own module and required using (require (for-syntax "bleh.rkt")).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!