At Sun, 05 Aug 2018 11:40:25 -0400, Christopher Lemmer Webber wrote:
> Eventually I would like to write a multiplayer game in Racket where
> users can write and execute code safely [...]
> 
> In a sense, it would sound as if Racket's #lang support would be perfect
> for this.  But in fact there is a problem with the #lang approach here:
> while a #lang, once selected, can constrain the language features
> available, the fact that one can select a #lang itself indicates that
> doing "#lang w7" is not the right approach.

The `get-info` function of `setup/getinfo` may be a useful model of how
to make a constrained `#lang` work for your purposes.

An "info.rkt" for collection or package info must be written in `#lang
info` to constrain the things that an "info.rkt" file can do. The
requirement to use `#lang info` is enforced by not loading the modules
directly, but by using `get-info`, which checks the module's language
before doing anything interesting (such as expanding the module).

The implementation has two main parts:

 * Set `current-reader-guard` to ensure that no readers are used other
   than the intended language's reader.

 * Check the result of `read-syntax` to make sure it's a module that
   uses the right language.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to