[racket] Weird Require Syntaxes

From: synx (plt at synx.us.to)
Date: Sat Sep 11 01:51:31 EDT 2010

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In my efforts to create a dynamically loading environment, I'd like to
do something like this:
- ---
#lang racket/base

(define-for-syntax db (something))
(define-for-syntax (get-env key) (db-value db key))

(define-syntax env
  (lambda (form)
    (syntax-case (form) ()
      (#'(_ key)
       (let ((key (syntax->datum (cadr form))))
         (do-something-to
          key
          (datum->syntax
           form
           (get-env key)
           form)))))))

(require (env some-key))
- ---

But for the life of me I can't figure out how to do it. I looked into
the import and import-source structures, but neither of them specify
anything in regards to the value of what's being required. They just
name it and the value is somehow acquired by other means. I tried
putting something random in for the src-mod-path like 'env/foo but then
racket actually tries to find and read the "env/foo.rkt" file in the
current collections path, and won't just call get-env like I was hoping for.

Basically what I'm looking for is some way to have the modules required
be an evaluable module form returned by just some procedure, instead of
being filesystem files or planet packages. The procedure would get the
module from a database, and possibly as a side effect also trigger the
recalculation of any other evaluation contexts that require that
particular module.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMixjiAAoJECC/cKf8E7UIXAUH/2Zf3NsJ+jiJ47F3LRHh28Y2
8wNMbI3W/JhPlQLBSDga5p3qEzrLX17cHFm3Tx8eE4vMLPVd7+gz2QKTWvNPFz6Q
37chCXsHfUnnCP3rOMBvqoJKz2mlvfqjLj4F+/GDxwR+Ua3UAsocKvvk7TlT8yM7
/lmVKIP1WcMLXLMLst+HuUYjFYMOzOtmog1x4/nA66cYJiDD1IgX1gX9h1HxqyDP
HNFYih43fE4IZUXERBfFDW9C48Wj3cgcauiWfGmh+2GdrDvnJP+SzRSCnInJSpTT
Fp/V3MCceoN9ue9RNEktze/ym4ixnXUra+nBOHCgwImh8BSSWbu3AZIGGNLDWAQ=
=SsEf
-----END PGP SIGNATURE-----


Posted on the users mailing list.