racket - Change literal dynamically in scheme -


i want write method takes literal, lets say

turn 

end returns this

(my turn) 

so, after that, if call eval, scheme call defined method my parameter turn.

i did manage return literal or string, didn't manage wanted. , didn't find specification this.

i assume have somehow use this: `(my,@param) doesn't work.

turn symbol

sounds xy problem me, perhaps there's simpler way achieve really intend do… anyway, answering question:

; need prevent evaluation of parameter, ; normal procedure won't work here - need macro (define-syntax method   (syntax-rules ()     ((_ x) '(my x))))  ; sample input (define turn 9) (define (my param) (+ 1 param))  ; setup evaluation namespace (define-namespace-anchor a) (define ns (namespace-anchor->namespace a))  ; first test: `method` returns non-evaluated expression (method turn) => '(my turn)  ; second test: evaluate returned expression (eval (method turn) ns) => 10 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -