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.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 imports its
> export.  Or does it actually do so via an effect?  I see there are some
> channels involved (input-ch / result-ch) so maybe it's passing back the
> result through there, but I am having trouble figuring out how.
>
> Having said all that, maybe I can envision a way to make it work:
>
>  - Have a parameter that, when parameterized, sets up the expected
>    channel that a module, upon being loaded, is expected to return its
>    "result" from.
>  - When evaluating the module, parameterize that channel; read from
>    it after evaluating and extract the value.
>
> Does that seem like the right approach?  I guess I will give it a try,
> anyway.

Well I gave it a try and couldn't quite figure out how to make it work.
I tried writing out this file, dungeon/room-ch.rkt:

```
#lang racket/base

(provide current-room-channel)

(define current-room-channel
  (make-parameter #f))
```

Then I tried writing test-read-ch.rkt:

```
#lang racket

(require dungeon/room-ch)

(define test-prog
  "#lang racket/base

(require dungeon/room-ch)

(channel-put (current-room-channel) 'foo)")

(define (try-reading)
  (parameterize ([read-accept-reader #t]
                 [current-room-channel (make-channel)])
    (eval (call-with-input-string test-prog read))
    (channel-get (current-room-channel))))
```

It just hangs, so I assume that the module never wrote to that channel.
I guess it probably wouldn't until it's required, but I have no idea how
to "require" this dynamically-read-in module to prime it?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/87woc7hado.fsf%40dustycloud.org.

Reply via email to