# Rhombus and racket/sandbox

**URL:** <https://racket.discourse.group/t/rhombus-and-racket-sandbox/2645>\
**Category:** General\
**Created:** [January 4, 2024, 4:27pm UTC](https://racket.discourse.group/t/rhombus-and-racket-sandbox/2645 "2024-01-04T16:27:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yfzhe](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@yfzhe](https://racket.discourse.group/u/yfzhe)\
**Post date:** [January 4, 2024, 4:27pm UTC](https://racket.discourse.group/t/rhombus-and-racket-sandbox/2645/1 "2024-01-04T16:27:59Z")

</div>

I recently tried to update my "racket eval bot", which uses `racket/sandbox` to evaluate racket (and typed/racket) code, to support Rhombus. But I failed, neither `make-evaluator` nor `make-module-evaluator` works.

```scheme
> ((make-evaluator 'rhombus) "1+2")
program: #%module-begin: expected more terms
  at:
  within: (#%module-begin)
  in: (#%module-begin)
 [,bt for context]
>
> ((make-module-evaluator "#lang rhombus") "1+2")
#%top-interaction: bad syntax
  in: (#%top-interaction . 1+2)
 [,bt for context]

```

I think the cause is the following code from `racket/sandbox`, which uses `read-syntax` from (#lang) racket. It means only s-exp code is support (natively) by `racket/sandbox`. Although using `parse-all` from shrubbery with `#:mode 'interactive` is a possible solution, I want a more gerenal way to evaluate non-sexp code, such as #lang datalog, with `racket/sandbox`.

> <https://github.com/racket/racket/blob/43152a74f1f653f1ae478459d37a39060d89d99d/pkgs/sandbox-lib/racket/sandbox.rkt#L114-L115>

After reading some code of DrRacket and racket-mode and partial understanding how their REPLs work, I attempted to `dynamic-require` the `configure-runtime` submodule in the evaluator, to update `current-read-interaction` and access its value. But I also failed.

Is it possible to let `racket/sandbox` to support non-sexp code in general?

And I noticed `scribble/rhombus`, which also uses `racket/sandbox` (through `scribble/example`) to evaluate rhombus code. However, it first reads (or parses) the code into s-exps, and then "applies" `examples` with these s-exps. How can we continue to support this usage if the answer to the former question is yes, in other words, how can we support both the raw representation of one non-sexp #lang and the parsed s-exp representation of it in `racket/sandbox`?

---

<div class="post-metadata">

**Author:** ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)\
**Post date:** [January 4, 2024, 5:13pm UTC](https://racket.discourse.group/t/rhombus-and-racket-sandbox/2645/2 "2024-01-04T17:13:01Z")

</div>

Perhaps take a look at [https://github.com/AlexKnauth/scribble-code-examples](https://github.com/AlexKnauth/scribble-code-examples), which uses the sandbox to generate examples in Scribble of non S-expression languages.

---

<div class="post-metadata">

**Author:** ![yfzhe](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@yfzhe](https://racket.discourse.group/u/yfzhe)\
**Post date:** [January 5, 2024, 3:00am UTC](https://racket.discourse.group/t/rhombus-and-racket-sandbox/2645/3 "2024-01-05T03:00:30Z")

</div>

Thanks! This is very helpful.

---

<div class="post-metadata">

**Author:** ![yfzhe](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@yfzhe](https://racket.discourse.group/u/yfzhe)\
**Post date:** [January 7, 2024, 5:49am UTC](https://racket.discourse.group/t/rhombus-and-racket-sandbox/2645/4 "2024-01-07T05:49:48Z")

</div>

Update: I tried the `configure-runtime` approach again, and succeeded. Set `sandbox-run-submodules` to `'(configure-runtime)`, then read the value of `current-read-interaction` with `call-in-sandbox-context`. It can be used as `read-syntax` for interactive evaluation.
