Commit 204e1efd authored by Robert P. Goldman's avatar Robert P. Goldman

Merge from Hugo Ishimaru with edits.

Merge commit '356c662f' into
hishimaru/asdf-man-fix2

Added index entries and minor copy editing.
parents 7875178f 356c662f
......@@ -1942,6 +1942,10 @@ of output from ASDF operations.
@node The package-inferred-system extension, , Other code in .asd files, Defining systems with defsystem
@section The package-inferred-system extension
@codequoteundirected on
@cindex Package inferred systems
@cindex Packages, inferring dependencies from
@findex package-inferred-system
Starting with release 3.1.2,
ASDF supports a one-package-per-file style of programming,
......@@ -2003,10 +2007,10 @@ packages used or provided by your system and its components
when the name of the system that provides the package
is not the downcase of the package name.
Then, the file @file{interface/order.lisp} under the @code{my-lib}
hierarchy will start with the following @code{define-package} form.
ASDF will infer the file's dependencies from the @code{:use} and
@code{:mix} clauses of that form.
Then, each file under the @code{my-lib} hierarchy will start with a
package definition, dependencies being computed from the
@code{:use} and @code{:mix} clauses. Take a file
@file{interface/order.lisp} as an example:
@example
(uiop:define-package :my-lib/interface/order
......@@ -2018,20 +2022,52 @@ ASDF will infer the file's dependencies from the @code{:use} and
@end example
ASDF can tell that this file depends on system @code{closer-mop} (registered above),
and files @code{my-lib/interface/definition}, @code{my-lib/interface/base}.
@code{my-lib/interface/definition}, @code{my-lib/interface/base}
(package and system names match, and they will be looked up hierarchically).
How can ASDF find the file @file{interface/order.lisp} from the
toplevel system @code{my-lib}, however? In the example above,
@file{interface/all.lisp} (and other @code{all.lisp}) will reexport
all the symbols at once from the packages at the same or lower levels
of the hierarchy. This can be easily done with
@code{uiop:define-package}:
@example
(uiop:define-package :my-lib/interface/all
(:nicknames :my-lib-interface)
(:use :closer-common-lisp)
(:mix :fare-utils :uiop :alexandria)
(:use-reexport
:my-lib/interface/definition
:my-lib/interface/base
:my-lib/interface/order
:my-lib/interface/monad/continuation))
@end example
Thus you have only to refer to each @code{my-lib/.../all} system
in the toplevel system because ASDF detects
@file{interface/order.lisp} and all other dependencies from the
@code{:use-reexport} clause.
@findex define-package
@findex uiop:define-package
The form @code{uiop:define-package} is supported as well as
@code{defpackage}, and has many options that prove useful in this
context, such as @code{:use-reexport} and @code{:mix-reexport} that
allow for ``inheritance'' of symbols being exported.
ASDF also detects dependencies from @code{:import-from} clauses.
You may thus import a well-defined set of symbols from an existing
package, and ASDF will know to load the system that provides that
package. In the following example, ASDF will infer that the current
system depends on @code{''foo/bar''} from the first @code{:import-from}.
system depends on
@code{''foo/bar''} from the first @code{:import-from}.
If you prefer to use any such symbol fully qualified by a package prefix,
you may declare a dependency on such a package and its corresponding system
via an @code{:import-from} clause with an empty list of symbols. For
example, if we preferred to use the name `foo/quux:bletch`, the second,
empty, @code{:import-from} form would cause ASDF to load
@code{"foo/quux''}.
@code{''foo/quux''}.
@example
(defpackage :foo/bar
......@@ -2076,6 +2112,7 @@ where the @file{.asd} file resides.
@c See this blog post about it:
@c @url{http://davazp.net/2014/11/26/modern-library-with-asdf-and-package-inferred-system.html}
@codequoteundirected off
@node The object model of ASDF, Controlling where ASDF searches for systems, Defining systems with defsystem, Top
@comment node-name, next, previous, up
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment