I’m working at the Racket REPL via
racket-mode in Emacs, writing code in multiple modules.
Is there a way to execute a single form from a module I’m not currently ‘in’, in the context of its own module?
#lang racket (require "view.rkt") (define (display-default-view) (display (default-view)))
#lang racket (provide default-view) (define default-text "Hello") (define (default-view) (string-append " world")
If I call
web.rkt I get a prompt saying
web.rkt>. If I then run
(display-default-view) I get “Hello world”.
If I then visit
view.rkt and change the default-text definition to:
(define default-text "Hi")
and re-evaluate the
default-text definition, it evaluates fine, and my prompt still says
When I enter
default-text at the REPL I get “Hi”. But when I run
(display-default-view) I still get “Hello world”. I’m presuming this is because all I’ve done is define a new
I’d expect to see output change to “Hi world” — i.e. the behaviour of the
view.rkt module to be updated. Just like I’d see if
default-text lived in the
The idea of dynamically re-evaluating single forms at the repl to change program behaviour is terrific, but it seems to not quite work here.
Is there a way to get this behaving as I would expect in racket-mode? Or if not, a mechanism to just enter a module, without running it, so that I can build something myself to do an enter-execute-exit dance?