gpt4 book ai didi

emacs - Racket REPL 和子模块

转载 作者:行者123 更新时间:2023-12-04 15:20:52 26 4
gpt4 key购买 nike

有没有一种简单的方法可以在 emacs 中以 Racket 模式在当前文件中加载子模块?

例如,如果我有以下文件

#lang racket

(define (foo x)
x)

(module+ sub
(define (bar x y)
x))

我在 Racket 模式下按 f5 启动 repl 然后 foo可用,但 bar不是。

最佳答案

可以结合 dynamic-enter! quote-module-path 去做这个。

给定您发布的上述代码的 repl 交互:

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

或者,您可以使用 dynamic-require/expose (暴露部分允许您需要未提供的东西),正如 here 所做的那样.

关于emacs - Racket REPL 和子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32185585/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com