从命令行启动Lisp程序时,如何指定软件包名称? [英] How can I specify the package name when launching a Lisp program from the command line?

查看:73
本文介绍了从命令行启动Lisp程序时,如何指定软件包名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Shell脚本中调用Lisp函数(以及其他一些东西).为简洁起见,以下是脚本的相关部分:

I'm calling a Lisp function (and a few other thing) from a shell script. For brevity, below is relevant part of the script :

./gcl -load/tmp/calendrica-3.0.cl -batch -eval'(格式T〜a" (CC3 :: sunset(CC3 :: fixed-from-gregorian(CC3 :: gregorian-date 1996 CC3 :: February 25)CC3 :: jerusalem)' 728714.7349874675

./gcl -load /tmp/calendrica-3.0.cl -batch -eval '(format T "~a" (CC3::sunset (CC3::fixed-from-gregorian (CC3::gregorian-date 1996 CC3::february 25)) CC3::jerusalem))' 728714.7349874675

上面的代码可以正常工作,但是我必须为使用的每个符号附加包名称CC3.这使得代码笨拙且难以键入.

The above code works fine but I had to append the package name CC3 for every symbol that is used; which makes the code unwieldy and hard to type.

我尝试使用use-package来简化它:

./gcl -load/tmp/calendrica-3.0.cl -batch -eval'(格式T〜a" (使用程序包"CC3")(日落(固定日期,从格里高利安(格里高利安日期为1996年2月25日)),耶路撒冷))'

./gcl -load /tmp/calendrica-3.0.cl -batch -eval '(format T "~a" (use-package "CC3") (sunset (fixed-from-gregorian (gregorian-date 1996 february 25)) jerusalem))'

更容易阅读和输入,但不幸的是它不起作用.我已经尝试过各种方法来包含use-package指令,但到目前为止没有成功.

Much easier to read and type, but unfortunately it doesn't work. I've tried all sorts of ways to include the use-package directive but so far no success.

在通过GNU Common Lisp(gcl)加载指令启动Lisp程序时,甚至有可能包含use-package指令吗?

Is it even possible to include a use-package directive while launching a Lisp program via the GNU Common Lisp's (gcl) load directive?

更新: 解决方案是使用已接受答案建议的多个评估.

Update: The solution is to use multiple evals as suggested by the accepted answer.

./gcl -load/tmp/calendrica-3.0.cl -batch -eval '(使用程序包"CC3")'-eval'(格式T〜a"(日落 (from-gregorian(gregorian-date 1996年2月25日))耶路撒冷))'

./gcl -load /tmp/calendrica-3.0.cl -batch -eval '(use-package "CC3")' -eval '(format T "~a" (sunset (fixed-from-gregorian (gregorian-date 1996 february 25)) jerusalem))'

推荐答案

也许您可以使用多个eval,这是我对sbcl的处理.

Maybe you could use multiple eval, here is what I do with sbcl.

#!/bin/sh
sbcl --noinform \
   --eval '(load "boot.lisp")' \
   --eval '(in-package #:my-pkg)' \
   --eval "(do-something-useful)" # do-something-useful is in my-pkg

这篇关于从命令行启动Lisp程序时,如何指定软件包名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆