Try to search your question here, if you can't find : Ask Any Question Now ?

Racket-Mode: Can I evaluate a single form within a given namespace at the REPL?

HomeCategory: stackoverflowRacket-Mode: Can I evaluate a single form within a given namespace at the REPL?
pushpa asked 3 weeks ago

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?

For instance:


#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 racket-run from 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 web.rkt>.

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 default-text in web.rkt.

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 web.rkt module.

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?

1 Answers
Best Answer
Mikhail answered 3 weeks ago
Your Answer

7 + 6 =

Popular Tags

WP Facebook Auto Publish Powered By :