You don't necessarily need to define a package to use code from other
files. Simply put,
package
is a means of abstraction and separation of your code from other code. It's
not designed to keep information about which file depends on which.
To organize your files (there are usually many files that are all reside in
one package), you need a thing called system, at least in ASDF terminology.
Before we speak about ASDF, I want to note that your load
method can be
used too, although it's rather suitable for toys, simple sketches, or for
use at REPL. You can manually load
things — it should work. If it doesn't
work for you, first try to specify full path to your file. Next thing you
can do if specifying full path helps, is make sure your CL implementation
knows where to search for the file if file name is relative. But this is a
different topic, and not very interesting one.
Normally, ASDF is used
nowadays to organize all sorts of projects, from small to big. You should
study the documentation to understand how to use ASDF, but even simple
example can tell your a lot:
(asdf:defsystem "hello-lisp"
:description "hello-lisp: a sample Lisp system."
:version "0.0.1"
:author "Joe User <[email protected]>"
:licence "Public Domain"
:components ((:file "packages")
(:file "macros" :depends-on ("packages"))
(:file "hello" :depends-on ("macros"))))
Here you can have some meta-data about your project, and the most important
thing — information about structure of the project. I think it's pretty
self-explanatory.
How to get ASDF? Good news for you, since you mentioned that you're using
SBCL, it's already installed.
As a rule, every programming language has some sort of ecosystem, that
allows you to define structure of your programs (dependencies between files
and external dependencies — libraries, etc.). It's an important thing to
learn. In Common Lisp world such an ecosystem is formed by combination of
ASDF and Quicklisp — library manager that
allows you to automatically install dependencies of your project, for
example. Plan your journey carefully and take a look at these tools!
(:use :cl :file)
will fail if there's no package named file. Doesfile.lisp
define one? – Jillianjillie