I'm reading the book Practical Common Lisp and I'm at chapter 25 now. For each chapter I create a folder in my book's folder, containing the chapter's system definition file, package definition file and the code. In chapter 25, I'll need the package I built in chapter 24, so the package definition for chapter 25 will look like this:
(defpackage :chapter-25-package (:use :common-lisp :chapter-24-package))
But chapter-24-package isn't in the Chapter 25 system. Can I use it in this package without having to include it in the system? Note: They are in separate folders within a same folder.
This is my system definition. There are links to all the necessary files in chapter 24 system inside chapter 25 folder. If any of them aren't necessary, please let me know.
(defpackage #:chapter-25-asd (:use :cl :asdf) (:export :chapter-25-system))
(in-package :chapter-25-asd)
(defsystem chapter-25-system
:name 'chapter-25-system
:components
((:file "chapter-25-package" :depends-on ("chapter-24-package"))
(:file "chapter-25" :depends-on ("chapter-25-package")))
:depends-on ("chapter-24-system"))
This is the error I get:
Component "chapter-24-package" not found, required by
#<CL-SOURCE-FILE "chapter-24-system" "chapter-24">
[Condition of type ASDF/FIND-COMPONENT:MISSING-DEPENDENCY]
Edit: This is the second question I make so I'm sorry if there is any bad practice. I appreciate if you let me know.
In short, no, but you can depend on the other system.
In order to depend on a different system, use the :depends-on
key in the system definition.
chapter-25.asd
:
(defsystem "chapter-25"
:depends-on ("chapter-24")
:components ((:file "package")
(:file "chapter-25" :depends-on ("package"))))
Assuming that a system "chapter-24" is defined in a file "chapter-24.asd" where ASDF can find it, this makes ASDF ensure that the system "chapter-24" is loaded before the system "chapter-25" is loaded.
In the code of the system "chapter-25", you can then assume that packages defined in the system "chapter-24" are loaded and can be referenced, e. g. through the :use
option of defpackage
:
(defpackage #:chapter-25
(:use (#:cl #:chapter-24)))