球拍REPL和子模块

Max*_*New 6 emacs racket

有没有一种简单的方法让我在emacs的racket-mode中加载当前文件中的子模块?

例如,如果我有以下文件

#lang racket

(define (foo x)
  x)

(module+ sub
  (define (bar x y)
    x))
Run Code Online (Sandbox Code Playgroud)

然后我在racket-mode中按f5启动repl然后foo可用但bar不是.

Lei*_*sen 5

你可以结合dynamic-enter!quote-module-path来做到这一点。

鉴于您发布的上述代码的 repl 交互:

> (require racket/enter syntax/location)
> (dynamic-enter! (quote-module-path sub))
> bar
#<procedure:bar>
Run Code Online (Sandbox Code Playgroud)

或者,您可以使用dynamic-require/expose(公开部分允许您需要未提供的内容),如在此处完成。