[racket] context switching

From: synx (plt at synx.us.to)
Date: Sat Jun 19 13:37:36 EDT 2010

Hash: SHA1

On 06/14/2010 12:47 PM, Jakub Piotr Cłapa wrote:
> Why do you want to have your context in parameters in the first place?

Eh, I don't really. I just like how they clean themselves up after
leaving a parameterization, without the attendant loss of
tail-optimization that happens with dynamic-wind. The whole "parameters
are thunks" thing is a bit clunky, but doesn't seem unreasonable. What I
want is to make a syntax form (perhaps an entire language) that lists
what identifiers are parameters on top, and munges the code to add the
parentheses when the parameters are not being set or re-parameterized. I
haven't quite figured exactly how to do that though.

> If you want to use multithreading then using parameters the way you do
> will result in a diverging world.

The context of the world would remain the same though. I'm only thinking
like, the context of the current room you're in, in the current
environment, at the current time of day, or other changeable things like

> I don't think raw PLT Scheme is dynamic enough for this. 

I think eval is dynamic enough for just about anything...

> As I see it you should build a dynamic (maybe
> Smalltalk like, you may check schemetalk from SCG.unibe.ch) object
> system with support for loading classes from disk at runtime (easy) and
> switching them without restarting the server.

Or I could just use Racket's object system, which seems pretty nice.
Just (sandbox-eval '(define current-room (new room% (description "...")
(parent inside-environment) (contents bell book candle) ...))) then I
have a room in my evaluation context whose identifier is "current-room"

Perhaps more usefully, (sandbox-eval (send current-room get-property

> You may also check the DGD
> MUD driver (it is a MUD driver based on a new implementation of the LPC
> language and really nice persistency features; it seems to have quite a
> good overal design).

Sure, but it's a totally different language. I wanted to make something
written in Racket and extended in Racket. I bet LPC doesn't have
re-entrant continuations, or optimize tail calls, or custom syntax forms.

> You also really need some ways to protect yourself agains malicious and
> runaway code. (threads and kill-thread are good but you must check that
> all your code is kill-safe)

Er, my plan was to run all code in various sandboxed evaluators, since I
have to evaluate it anyway upon retrieval from disk. Shouldn't be overly
dangerous. Most of the things in scheme/base such as make-directory,
open-input-file, or tcp-connect are already disabled by default in a
sandbox, and can always be enabled for authorized players.
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/


Posted on the users mailing list.