Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-11 Thread Christopher Lemmer Webber
Jay McCarthy writes: > I feel like I might not understand what you want, but it feels like > you just want to use `make-module-evaluator` from `racket/sandbox`: > > ``` > #lang racket/base > (require racket/sandbox) > > (define (read-script s) > (((make-module-evaluator s) 'script) 5)) > > (modu

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-11 Thread David Storrs
Don't forget to handle multiple value return. What will you do if the last line in the file is (values a b)? Also, side effects. Do you care if someone includes a print/write/display statement? You mentioned that the code would be safe, so presumably tcp-connect and sqlite3-connect are not issues.

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Jay McCarthy
I feel like I might not understand what you want, but it feels like you just want to use `make-module-evaluator` from `racket/sandbox`: ``` #lang racket/base (require racket/sandbox) (define (read-script s) (((make-module-evaluator s) 'script) 5)) (module+ test (read-script "#lang racket/

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Christopher Lemmer Webber
Hey Eric! Thanks, I'll try to soak in this a bit tomorrow. :) Eric Griffis writes: > This works: > > 1. mkdir foo; cd foo; raco pkg install > > 2. create foo/main.rkt: > > ``` > #lang racket/base > > (module reader racket/base > (require racket/port) > (provide (rename-out [foo-read read] >

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Eric Griffis
This works: 1. mkdir foo; cd foo; raco pkg install 2. create foo/main.rkt: ``` #lang racket/base (module reader racket/base (require racket/port) (provide (rename-out [foo-read read] [foo-read-syntax read-syntax])) (define (foo-read port) `(module ,(gensym 'foo)

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Christopher Lemmer Webber
Well, I think I figured out how to get further: with example1.rkt being: ``` #lang racket/base ;; #lang dungeon/misery (define ((make-start-game read-save-file) player-name) (list 'running-this-read-save-file: read-save-file 'on-player-name: player-name 'result: (read-save-file

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Christopher Lemmer Webber
Hi Eric! Thanks very much for the reply. Eric Griffis writes: >> It appears there must be; when I look at `build-program` in >> sandbox.rkt it also looks like it's wrapping things in a module >> structure... but I don't see how it then exports from that module or >> how the code evaluating it im

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Eric Griffis
On Sun, Nov 10, 2019 at 6:45 AM Christopher Lemmer Webber < cweb...@dustycloud.org> wrote: > > It sounds like what I want is the case of the export. I'll run with this. > I guess a question remaining then is: if I'm doing this kind of dynamic > import of the module, is there a way to require from

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Christopher Lemmer Webber
Christopher Lemmer Webber writes: > I guess a question remaining then is: if I'm doing this kind of dynamic > import of the module, is there a way to require from it (especially if > it isn't assigned to a "filename" on disk?). It appears there must be; > when I look at `build-program` in sandbox

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-10 Thread Christopher Lemmer Webber
Thanks Jay for the helpful response as usual Jay; I really do appreciate it. It sounds like what I want is the case of the export. I think I can figure out how to modify the #%module-begin to do that. I guess a question remaining then is: if I'm doing this kind of dynamic import of the module, i

Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-09 Thread Jay McCarthy
Modules don't evaluate to values. They have effects and they have exported symbols. If you want to observe the evaluation of your language's module, you'll have to look at one of those two things. Both are used by existing Racket languages and infrastructure: `raco test` relies on test modules maki

[racket-users] Evaluating to get the output with a specific lang

2019-11-09 Thread Christopher Lemmer Webber
(Caveat: I know the sandbox evaluator exists. I'm trying to understand how to do this without it, to understand the evaluation machinery for something.) Let's say I write "#lang foo". For whatever reason, I have programs that are coming in from users that are not necessarily being saved to a fil