如何通过命令行将文件加载到球拍中? [英] How do you load a file into racket via command line?
问题描述
我一直在尝试从命令行(通过球拍")启动球拍程序,但没有成功.根据文档(这里 http://docs.racket-lang.org/reference/running-sa.html#%28part._mz-cmdline%29) 传递 -f
后跟一个文件应该评估该文件.但是,我似乎无法让它发挥作用.作为测试,我制作了以下文件:
I have been trying to launch a racket program from the commandline (via 'racket') but have not been having success. According to the documentation (here http://docs.racket-lang.org/reference/running-sa.html#%28part._mz-cmdline%29) passing -f
followed by a file should evaluate that file. However, I can't seem to get this to work. As a test, I made the following file:
;test.rkt
#lang racket
(define a 1)
然后,在球拍中运行它(据说是加载文件)并尝试调用 a 的值:
Then, running it in racket (supposedly loading the file) and attempting to recall the value of a:
racket -f test.rkt -i
Welcome to Racket v5.1.1.
> a
reference to undefined identifier: a
我的最终目标是能够使用 --main
选项结合使用 -f
加载定义以启动从 shell 脚本启动不同的程序执行,只是变得有点困惑,因为我似乎无法让这个微不足道的部分工作.
My end goal is to be able to launch a different program from a shell script using the --main
option combined with loading the definitions with -f
to start up execution, just have become a bit baffled since I can't seem to get this trivial bit working.
推荐答案
从文件中删除 #lang racket
标题:
Remove the #lang racket
header from your file:
;test.rkt
(define a 1)
这篇关于如何通过命令行将文件加载到球拍中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!