[racket] context switching

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

-----BEGIN PGP SIGNED MESSAGE-----
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
that.

> 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
"some-program"))

> 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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMHQBgAAoJECC/cKf8E7UIbyAIAIqlQg4HMfgen4mCaaengNep
tH6eCsz+5i395/LPfUjG/W1/tR+KpiI5engxmcoSnPxCyNe7Iu+w6wtqfBR0zNv2
0X52CVoeJ4ke+uLUNx9LLHDlJTfMPgLgONTuoSGKZJIhNq/QGgv9AGdKZ4dzoo0i
f2AldMjn2hO7OSyqU/Wxc8UY6ZK6eUjgcYRhf0y8yFBwhUbWmwl2uVUTiU+7o3s6
7ZSxzx2hPYQobVkjgpWYJnMYAaSJ7ybKui28dH0oVAcbaSVeKLFB09fu6I48BOt+
tY7eCHpwwpRzDDgWBCm49w0PiK/PH7nWAIfi2UvIE85Z6Wy6ExQEhW4ogLLnXWM=
=eASo
-----END PGP SIGNATURE-----


Posted on the users mailing list.