Re: packages, load paths and environment variables
- From: Pascal Bourguignon <usenet@xxxxxxxxxxxxxxxxx>
- Date: Wed, 05 Apr 2006 15:12:12 +0200
Holger Schauer <Holger.Schauer@xxxxxx> writes:
There is really no reason to separate package from source code files,
although it is good practice to do so.
There is one reason. The same why in Modula-2 and Modula-3 you
separate definition modules from implementation modules.
If you don't have macros (which adds another complexity), the
dependencies between modules don't go directly from one implementation
module to another, but actually from one implementation module to
another definition module: to use a CL package from the sources of
another, you only need the package definition of the first (you only
need to know the exported symbols, they don't need to have themselves
a definition yet).
Therefore when you have CL sources with crossed dependencies, you need
to cut off the package definition which don't depend one on the
other.
If you had (defpackage :a (:use :b) (:export :f))
(defpackage :b (:use :a) (:export :g))
you could resolve by removing :B from the use list of A,
and add a (use-package :b) in the sources (implementation module) of A.
Now, in Lisp, dependencies can be more complicated anyways for the
macros, and their need to be loaded (along with the functions they
use) at compilation time.
When you want to use a macro such my DEFINE-PACKAGE, you're actually
imposing restrictions on the dependencies between the various lisp
sources (removing circular dependencies in my case).
When you say that there is no reason to separate the package
definition from the sources, you're saying that there's no reason to
have circular dependencies. Well, sometimes there are reasons, but I
agree that it'd be better to avoid them.
So what's the solution? What I'm interested in understanding, at the
moment, is if there's a way to create yet another wrapper that will
conceal all this horrible complexity. This wrapper would merely mimic
the easy packaging of lesser langauges. In other words, it would let
you:
1) define a package through a single file, including its export list
and its imported dependencies
2) define package names in one-to-one correspondence with pathnames
3) automatically manage loading order
Do you want to suggest that there should be a 1:1 correspondence
between 'modules' (or whatever this system/package/feature-mix may be
named) and files? Or do I interpret to much into your idea?
One may want to define "module" in such a way. 1) & 2) clearly impose
a 1:1 correspondance between modules and files.
Alexis, you'll have to write your own module system to apply these rules.
(or just use my DEFINE-PACKAGE which implements these three rules).
--
__Pascal Bourguignon__ http://www.informatimago.com/
This universe shipped by weight, not volume. Some expansion may have
occurred during shipment.
.
- Follow-Ups:
- Re: packages, load paths and environment variables
- From: Holger Schauer
- Re: packages, load paths and environment variables
- References:
- Re: packages, load paths and environment variables
- From: Holger Schauer
- Re: packages, load paths and environment variables
- Prev by Date: Re: DST riddle
- Next by Date: Re: Memory-lapse CL question about eval and let
- Previous by thread: Re: packages, load paths and environment variables
- Next by thread: Re: packages, load paths and environment variables
- Index(es):
Relevant Pages
|
|