Re: packages, load paths and environment variables



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.
.



Relevant Pages

  • Re: Reason for Acyclic Dependency Principle
    ... > The main reason for Acyclic Dependency Principle is that circular ... > dependencies are undesirable because they make testing a system hard. ... > If class A in package A calls class B in package B and class B calls ... The solution is to let X take care of itself, and let C take care of ...
    (comp.object)
  • Re: DPS Initial Ideas
    ... of "The FreeBSD package system is broken and needs to be fundamentally ... Rewriting it to use SQLite is a fundamental change. ... running a perl script to connect to a Berkeley database. ... It may be that borrowing from Debian the idea of "abstract" dependencies ...
    (freebsd-hackers)
  • Re: Separate Compilation in Programming Languages
    ... for the Package P1 to the package body of P2. ... no need to recompile anything, ... This is not true in the traditional Ada way when the dependencies are ... package Stacks is ...
    (comp.lang.ada)
  • Re: DPS Initial Ideas
    ... of "The FreeBSD package system is broken and needs to be fundamentally ... to change dependencies which are in the correct range, ... without requiring a rewrite from scratch. ... think about making use of the INDEX file. ...
    (freebsd-hackers)
  • Re: Shipping in eBay
    ... >>> a good reason to not do so. ... >>> away from my job, kids, wife, etc. to mail this package to another ... No access to USPS? ... transaction online and the postman will pick up your package at your ...
    (rec.models.scale)