【发布时间】:2023-04-03 09:10:01
【问题描述】:
我 90% 确定答案在 this paragraph of the asdf documentation 中,但我似乎无法理解。 我想知道我是否能够将不以“.lisp”结尾的源文件作为文件组件。例如,通常我有类似的东西
(asdf:defsystem #:hash-bang-lang
:serial t
:depends-on (#:named-readtables)
:components ((:file "package")
(:file "hash-bang-lang")))
如您所见 :file 组件没有指定扩展名。我想知道是否可以加载不以“.lisp”结尾的 lisp 文件。
我想要这个的原因有点奇怪,但对问题没有影响,所以请随意跳过下一点。
我有一些文件“test.mylang”,它以以下内容开头
(in-package :hash-bang-lang)
(in-readtable hash-bang)
#!mylang
..rest of file..
#!mylang 是一个阅读器宏,它让我的#'mylang 函数控制解析文件的其余部分。因此,如果我有一个 python 解析器,我会使用 #!python 并且我的 #'python 函数将负责解析。
在这些情况下,我希望使用 .mylang 或 .py 扩展名,以便编辑人员立即知道如何突出显示代码,即使它无论如何都会被加载为 lisp。
谢谢大家
【问题讨论】:
-
我认为通过使用
#p"foo.py",它可能会起作用(如(:file #p"foo.py")。 -
怕不是
Error while trying to load definition for system hash-bang-lang .. There is no applicable method for the generic function .. FIND-COMPONENT .. when called with (#<ASDF:SYSTEM "hash-bang-lang"> #P"test.py")