Specify #lang for eval in Racket
Asked Answered
C

1

8

I want to use a specific #lang in eval to provide it its semantics. However, eval itself does not appear to have a mechanism to specify the language, and passing in #lang does not seem to work.

Cooke answered 24/10, 2015 at 20:50 Comment(0)
A
9

You can use make-module-evaluator from racket/sandbox for that.

> (require racket/sandbox)
> (define evaluator (make-module-evaluator "#lang racket/base"))
> (evaluator '(+ 1 2))
3
> (evaluator "(+ 1 2)")
3
Arnoldarnoldo answered 24/10, 2015 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.