Parameterizing current-output-port to (open-output-string) redirects
the output to a string. Something along the line of (open-output-file
"/dev/null") sounds a bit better but I'm not sure how to create a
discard-everything output port.
(define ns (make-base-namespace))
(parameterize ([current-namespace ns])
(eval '(module a racket
(displayln "a line from module a")
(define x 5))))
(printf "value of x is ~a\n"
(parameterize ([current-namespace ns]
(dynamic-require ''a 'x)))
On Mon, Aug 28, 2017 at 10:22 AM, Sam Waxman <samwax...@gmail.com> wrote:
> Let's say I have a module that looks like
> (module a racket
> (provide result)
> (print "Annoying print line!")
> (define result 2))
> and I'd like the value of result in another module, so in another module, I
> (require a)
> (dynamic-require ''a 'result)
> In both cases, I get the value of result, but by requiring the module, the
> print line "Annoying print line!" will show up on my screen and be part of
> the output of the program.
> Is there a way to get the value of result from module a without triggering
> the print, or hiding it in some way? I've played around with print-handlers,
> but it seems anything I do outside of module a won't affect the printer
> inside module a.
> 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.
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
For more options, visit https://groups.google.com/d/optout.