我正在为" Gnubik“程序编写Guile扩展脚本,在尝试使用来自”文本端口“模块的" get -string-all”函数时出错:当我从命令行启动Gnubik时,会打印错误文本,程序不会启动。当这个函数被使用在一个Guile shell脚本中时--这个问题不会发生。我安装了两个Guile软件包: 2.0和2.2。
错误文本如下:
Backtrace:
In ice-9/boot-9.scm:
160: 10 [catch #t #<catch-closure c86380> ...]
In unknown file:
?: 9 [apply-smob/1 #<catch-closure c86380>]
In ice-9/eval.scm:
505: 8 [#<procedure b5e540 at ice-9/eval.scm:499:4 (exp)> (use-modules #)]
In ice-9/psyntax.scm:
1107: 7 [expand-top-sequence ((use-modules (ice-9 textual-ports))) () ...]
990: 6 [scan ((use-modules (ice-9 textual-ports))) () ...]
279: 5 [scan ((# #) #(syntax-object *unspecified* # #)) () (()) ...]
In ice-9/boot-9.scm:
3622: 4 [process-use-modules (((ice-9 textual-ports)))]
712: 3 [map #<procedure c1ab40 at ice-9/boot-9.scm:3622:25 (mif-args)> ((#))]
3623: 2 [#<procedure c1ab40 at ice-9/boot-9.scm:3622:25 (mif-args)> (#)]
2903: 1 [resolve-interface (ice-9 textual-ports) #:select ...]
In unknown file:
?: 0 [scm-error misc-error #f ...]
ERROR: In procedure scm-error:
ERROR: no code for module (ice-9 textual-ports)欺诈代码:
(use-modules (ice-9 textual-ports))
(call-with-input-file "/tmp/tst.txt"
(lambda (port)
(define s (get-string-all port))))如何纠正这个问题?
发布于 2017-08-08 18:40:13
根据文档“(使用-模块(rnrs io端口))”。
为我工作。
编辑:在guile-2.0中,我看到get-string-all是由'(rnrs io端口)‘模块提供的,但在guile-2.2中,它是由'(rnrs io端口)’和'(ice-9文本-端口)‘模块提供的。
所以有两个问题。首先,您试图在guile-2.0中加载“(ice-9文本端口)”模块,因为它只由guile-2.2提供,因此无法工作。其次,您的lambda表单中没有表达式,它只需要返回get-string-all应用程序的值。
https://stackoverflow.com/questions/45575513
复制相似问题