我在一个文件中有这个(文件的名称是ExamplesFile.scm):
(define examples (with-input-from-file "examples.scm" read))
我知道数据已加载并存储在变量examples
如果我执行:
examples
在迭代窗口中,它给出了文件中的数据" examples.scm"。这很好。
稍后,在我写的同一目录中的另一个文件中:
(require "ExamplesFile.scm")
在第二个文件的迭代窗口中,定义了" ExamplesFile.scm"可用。但是如果我执行:
examples
我收到了这个错误:
examples: undefined;
cannot reference an identifier before its definition
我该如何解决?如何将读取的数据存储在第二个文件中的一个文件中?
答案 0 :(得分:2)
为了使examples
中的ExamplesFile.scm
绑定对其他需要它的文件可见,您需要使用(例如)
(provide example)
或者,如果您想provide
文件中定义的所有内容,您可以使用
(provide (all-defined-out))
所有这一切都假设您使用#lang racket
语言;你没有明确提到这一点。
如果我误解了你的问题,请道歉!