【问题标题】:Is there a way to run guile function from command line有没有办法从命令行运行 guile 函数
【发布时间】:2022-10-21 19:24:12
【问题描述】:

所以我有一个简单的file.scm 文件,其中包含以下代码:

#!/usr/bin/guile -s 
!#
(define (printer arg)
  (display arg))

我知道你可以通过 (load "file.scm") 在 guile repl 中执行它,然后调用像 (printer "this") 这样的函数。

有没有办法通过命令行终端 比如guile "file.scm" (printer "this")

【问题讨论】:

    标签: scheme guile


    【解决方案1】:

    根据the manual,类似

    guile -l file.scm -c '(printer "this")'
    

    将工作。

    【讨论】:

      【解决方案2】:

      您可以只使用 -e 标志

      guile -e printer file.scm 1 2 3
      

      或者更好

      #!/usr/bin/env -S guile -e printer
      !#
      
      (define (printer args)
        (display args))
      

      并运行为

      ./file.scm 1 2 3
      

      许多其他(官方)Guile 脚本示例:https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-20
        • 1970-01-01
        • 2015-03-12
        • 2021-08-01
        • 2016-01-17
        • 1970-01-01
        • 2012-08-15
        • 2023-04-01
        相关资源
        最近更新 更多