我在文件中有以下因子代码:
IN: set-work-dir
USING: shell ;
CONSTANT: work-dir "/code" ! I also tried "c:/code" and "c:\\code"--same error
work-dir cd
当我尝试从因素运行脚本时,我收到此错误:
C:\>/usr/bin/factor/factor /usr/bin/factor/work/set-work-dir.factor
Generic word absolute-path does not define a method for the fixnum class.
Dispatching on object: 47
(U) Quotation: [ c-to-factor => ]
Word: c-to-factor
(U) Quotation: [ [ (get-catchstack) push ] dip call => (get-catchstack) pop* ]
(O) Word: command-line-startup
(O) Word: run-script
(O) Word: set-current-directory
(O) Method: M\ object absolute-path
(O) Word: no-method
(O) Method: M\ object throw
(U) Quotation: [
OBJ-CURRENT-THREAD special-object error-thread set-global
current-continuation => error-continuation set-global
[ original-error set-global ] [ rethrow ] bi
]
如果不是USING: shell ;
我有,我可以让它USING: io.files.private
运行,但在脚本运行之外没有保留目录更改。我假设使用 shell 会导致目录更改持续存在——我意识到这可能是一个错误的假设。如何编写脚本来更改目录并使目录更改在脚本之外持续存在?
Windows 7(是的,我知道 Windows 上的目录分隔符通常是\
,我也尝试过 '\'。但/
实际上也适用于 Windows。除了当我使用 io.files.private 时路径有效)。
Windows 上的系数 0.98 x86.64(1788,heads/master-e187d63d3c,Tue Oct 18 02:14:22 2016)[Microsoft Visual C++ 190023506]