Runtime evaluation: Difference between revisions
Content added Content deleted
(+ blsq) |
|||
Line 730: | Line 730: | ||
> eval(expr1, env) |
> eval(expr1, env) |
||
[1] 11</lang> |
[1] 11</lang> |
||
=={{header|Racket}}== |
|||
Racket has the usual <tt>eval</tt> that is demonstrated [[http://rosettacode.org/wiki/Runtime_evaluation/In_an_environment#Racket here]], and in addition, it has a sandbox environment that provides a safe evaluator that is restricted from accessing files, network, etc. |
|||
<lang Racket> |
|||
#lang racket |
|||
(require racket/sandbox) |
|||
(define e (make-evaluator 'racket)) |
|||
(e '(define + *)) |
|||
(e '(+ 10 20)) |
|||
(+ 10 20) |
|||
;; (e '(delete-file "/etc/passwd")) |
|||
;; --> delete-file: `delete' access denied for /etc/passwd |
|||
</lang> |
|||
And, of course, both of these methods can use Racket's multilingual capabilities and evaluate the code in a language with different semantics. |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |