[ACCEPTED]-Lisp importing/loading file-lisp

Accepted answer
Score: 18

Use standard functions like LOAD and COMPILE-FILE.

ANSI Common 7 Lisp also has a function REQUIRE.

If you 6 use as 'system' maintenance tool as an extension 5 to Common Lisp, then you can also load or 4 compile a whole 'system'. A 'system' is 3 a collection of files and subsystems for 2 which operations like load and compile are 1 defined.

Score: 12

In addition to Rainer's answer:

If you want 16 to load ASDF-systems, use:

(asdf:load-system 'my-system)

Some Lisp implementations 15 (CCL for example) also allow using require for 14 loading ASDF systems, but that functionality 13 is implementation dependent. If you are 12 using Slime, and want to load a system interactively, you 11 can do so by typing ,l my-system at the Slime REPL.

Another 10 thing I wanted to point out is that, unlike 9 in Python, using require or load in CL does not have 8 anything to do with packages (think "namespaces"). So, if 7 the code you are loading or requiring lives 6 in its own package, you will either have 5 to use its exported symbols qualified (foo:bar), or 4 include those packages in the package your 3 code lives in ((defpackage my-package (:use cl package-you-want-to-use ...) ...)). This does not only differ 2 from Python imports, but also from C preprocessor 1 #includes, the latter being mere textual inclusions.

More Related questions