packages, load paths and environment variables
- From: Florian Leitner <fnl@xxxxxxx>
- Date: Tue, 28 Mar 2006 15:24:26 +0200
Hello,
so far I have been experimenting around with using packages the correct
way. I know this might seem a trivial question to many, yet it is
occupying me for a while. Also, after doing alot of searching I could
not come up with satisfying answers to my questions below.
Here is the setup:
package file: "foo.lisp"
------------------------
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FOO; Base: 10 -*-
(defpackage :foo
(:use :common-lisp)
(:export :fn-foo))
(in-package :foo)
(defun fn-foo ()
(print "in foo:fn-foo"))
------------------------
base file: "bar.lisp"
---------------------
(load "foo") ; w/o this, the next command, "USE-PACKAGE", fails
(use-package :foo)
(defun fn-bar ()
(fn-foo))
---------------------
Now, on the CLISP REPL I do the following:
------------------------------------------
CL-USER> (ext:cd "/path/to/my/lisp/dir")
....
CL-USER> (load "bar")
....
T
CL-USER> (fn-bar)
"in foo:fn-foo"
"in foo:fn-foo"
CL-USER>
------------------------------------------
First of all - is this by any means the way to do it?
What mainly bothers me, is the (LOAD "foo") in 'bar.lisp'. The only way
to avoid this, would be to write it on the REPL, but then I would have
to remember in which order I load my packages each time I start a new
lisp session. Is the only other way to manage this a central
"packages.lisp" file in which I state all my packages as (LOAD "foo")'s?
Additionally, I want to avoid giving absolute path names. With the above
method, I have to have all files in the same directory, which is not
what I actually want. The best way would be to have an (*nix/winXP/osX)
environment variable telling LISP where to look for .lisp files
requested by (LOAD), setting something like the CLISP or CMUCL-specific
CUSTOM:*LOAD-PATHS*
EXTENSIONS:*LOAD-SOURCE-TYPES* and *LOAD-OBJECT-TYPES*
lists at startup. I could not find a sort of "common Common LISP
load-path environment variable" for this? I guess at best there will be
implementation specific env. variables (and if so, I would be interested
specifically in the ones for CLISP and CMUCL, please - couldn't even
find something there...)?
This also leads right to my final question - is there a way to avoid
(LOAD) alltogether? Is there no way that (USE-PACKAGE) loads the
required package files all by itself, not having to load everything
beforehand?
Thanks for any help!
-Florian
.
- Follow-Ups:
- Re: packages, load paths and environment variables
- From: Pascal Costanza
- Re: packages, load paths and environment variables
- Prev by Date: CLISP in a box: adding functions at load time
- Next by Date: Re: packages, load paths and environment variables
- Previous by thread: CLISP in a box: adding functions at load time
- Next by thread: Re: packages, load paths and environment variables
- Index(es):
Relevant Pages
|
|