使用 plt 方案导入结构
我遇到了一个简单方案应用程序的问题。 在一个文件(dataloader.ss)中,我定义了一个结构:
(define-struct book-category (id name books))
但我无法在另一个文件中使用该结构。 我尝试的是,在 dataloader.ss 中,导出结构并
(provide book-category)
在另一个文件中,我导入:
(require "dataloader.ss").
但是对结构函数之一的调用不可避免地失败: 例如
(make-book-category 2 "test" '())
给我:
在其之前引用标识符 定义:make-book-category
另一方面,如果我重新定义第二个文件中的结构,它会告诉我: “模块:标识符已导入到:图书类别” 所以,我猜导入至少部分有效。但我仍然无法访问相关功能。还有其他事情要做吗?
提前致谢!
I'm struck on a problem with a simple scheme application.
In one file (dataloader.ss), I define a struct :
(define-struct book-category (id name books))
But I can't use the structure in another file.
What I try is, in dataloader.ss, to export the structure with
(provide book-category)
And in the other file, I import :
(require "dataloader.ss").
But a call to one of the struct functions irremediably fails :
For example
(make-book-category 2 "test" '())
gives me :
reference to an identifier before its
definition: make-book-category
On the other hand, if I redefine the struct in the 2nd file, it tells me :
"module: identifier is already imported in: book-category"
so, I guess the import works at least partially. But I still can't access the associated functions. Is there something else to do?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的找到了,我必须使用 struct-out 关键字导出,如下所示
Ok found it, i must export with the struct-out keyword, as in