从命令行启动Lisp程序时,如何指定软件包名称?

编程入门 行业动态 更新时间:2024-10-27 00:30:00
本文介绍了从命令行启动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程序时,如何指定软件包名称?

本文发布于:2023-11-16 20:02:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:软件包   命令行   名称   程序   Lisp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!