2017-06-28 8 views
1

我在一個文件中有這樣的定義(該文件的名稱是ExamplesFile.scm):球拍。爲什麼它不加載數據「需要」的時候,數據anoter文件

(define examples (with-input-from-file "examples.scm" read)) 

我明白數據加載和存儲在變量examples

如果我執行:

examples 
在迭代窗

它給出了在文件「examples.scm」的數據。這工作正常。

後來,在位於同一目錄的另一個文件我寫:

(require "ExamplesFile.scm") 

在第二個文件的iteraction窗口在「ExamplesFile.scm」中定義的功能可用。但是,如果我執行:

examples 

我得到這個錯誤:

examples: undefined; 
cannot reference an identifier before its definition 

我該如何解決呢?我怎樣才能獲得讀取並存儲在第二個文件中的一個文件中的數據?

回答

2

爲了使examples在結合ExamplesFile.scm到需要它,你需要顯式地提供它,使用(例如)

(provide example) 

另外,如果你想在定義provide一切其他文件可見文件,你可以使用

(provide (all-defined-out)) 

所有這一切都是假設你正在使用的語言#lang racket;你沒有明確提到這一點。

道歉,如果我誤解了你的問題!

相關問題