packages, load paths and environment variables



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
.



Relevant Pages

  • Re: Packages and ASDF
    ... How does my lisp implementation know ... And then how come for other packages (or systems, ... A "system" is whatever is handled by asdf. ... that asdf can load them. ...
    (comp.lang.lisp)
  • Re: fasl and lisp image
    ... fundamental difference between the lisp image and the set of .fasl ... need anything more than a remembered set of fasl to load (both ... When I work with a Lisp machine, ... When I later restart the Lisp, ...
    (comp.lang.lisp)
  • Re: DBMS and lisp, etc.
    ... boundaries in your system even if your crude backing store does not actually ... to toss out a real benefit of the DBMS and design around it at this point. ... structure and the simply "print" to save it, and then "read" to load it. ... you may want to look into some implementation specific bits of your Lisp, ...
    (comp.lang.lisp)
  • Re: Why Lisp is too hard for me to use
    ... Lisps and several libraries. ... so it needs implementation support. ... The current strong support for Lisp ... > This consists of simple .tar.gz packages, ...
    (comp.lang.lisp)
  • Re: Poll : Are you interested seeing Qi as embedded language in lisp?
    ... LOAD the following into Qi. ... why it wouldn't work on SBCL and other lisp implementations. ... Now, Qi doesn't have an asdf system definition, but it's a somewhat ... currently in a single file anyway, you just compile and load it and ...
    (comp.lang.lisp)