(module vandusen-eval () (import chicken scheme extras ports data-structures) (use vandusen sandbox srfi-18) (plugin 'eval (lambda () (define (reply-with-eval-result m expression) (condition-case (reply-to m (format "~S" (safe-eval (with-input-from-string expression read)))) (e () (reply-to m (format "Error: ~A~A" (get-condition-property e 'exn 'message) (let ((args (get-condition-property e 'exn 'arguments))) (if (null? args) "" (apply conc (cons ": " args))))))))) (command 'eval '(: "eval" (+ whitespace) (submatch (+ any))) (lambda (m expression) (thread-start! (lambda () (let ((thread (thread-start! (cut reply-with-eval-result m expression)))) (thread-sleep! 3) (thread-terminate! thread)))))))))