3

I am 90% sure the answer is in this paragraph of the asdf documentation , but I seem unable to grok it. I am wondering if I am able to have source files that do not end in ".lisp" as file components. For example, usually I have something like

(asdf:defsystem #:hash-bang-lang
  :serial t
  :depends-on (#:named-readtables)
  :components ((:file "package")
               (:file "hash-bang-lang")))

As you can see the :file components do not specify the extension. I am wondering if I can load lisp files that do not end in ".lisp".

The reason I want this is a little odd but has no impact on the question so feel free to skip the next bit.

I have some file "test.mylang" and it starts with the following

(in-package :hash-bang-lang)
(in-readtable hash-bang)
#!mylang
..rest of file..

The #!mylang is a reader macro that gives my #'mylang function control of parsing the rest of the file. So if I had a parser for python I would use #!python and my #'python function will take up the parsing. In those cases I would like to have the .mylang or .py extension so editors know instantly how to highlight the code, even though it's going to be loaded as lisp anyway.

Thanks folks

Baggers
  • 3,183
  • 20
  • 31
  • 1
    I think that by using `#p"foo.py"`, it might work (as in `(:file #p"foo.py")`. – Svante Mar 30 '15 at 09:24
  • 1
    Afraid not `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 (# #P"test.py")` – Baggers Mar 30 '15 at 13:14

1 Answers1

2

The :file component type forces the file extension to .lisp. If you need some other extension, you need a new component type.

(defpackage #:mylang-system
  (:use #:cl #:asdf))
(in-package #:mylang-system)

(defclass mylang-file (cl-source-file)
  ((type :initform "mylang")))

(defsystem test-ext
  :encoding :utf-8
  :components ((:file "package")
               (:mylang-file "hash-bang-lang")))
jlahd
  • 6,257
  • 1
  • 15
  • 21
  • Thanks, this will give me an excuse to look into the asdf extension mechanisms, that has been on my todo list for a while – Baggers Mar 31 '15 at 16:19