Home

inpackage

In Common Lisp, in-package is a special operator that changes the current package for subsequent evaluation. The current package acts as the namespace for symbols; switching packages affects which symbols are read, created, and exported by default. The common usage is (in-package :my-package) or (in-package "MY-PACKAGE"), and the named package must already exist; if the package does not exist, a package-error is signaled.

When in-package is evaluated, the reader and evaluator treat unqualified symbols as belonging to the new current

Packages themselves are defined and configured with defpackage, which specifies the package name, its nicknames, and

Notes on usage: the package name can be given as a symbol or a string; the exact

See also: defpackage.

package.
This
means
that
definitions
such
as
defun,
defvar,
and
other
top-level
forms
will
intern
their
symbols
in
the
current
package
unless
a
package
prefix
is
used.
In
this
way,
in-package
provides
a
convenient
way
to
organize
code
into
namespaces
and
avoid
naming
conflicts
across
large
projects.
which
packages
it
can
use
or
export
from.
Importantly,
in-package
does
not
create
packages
or
modify
their
exports;
it
only
sets
the
active
package
context
for
subsequent
code.
Developers
typically
place
an
in-package
form
at
the
beginning
of
a
source
file
to
establish
the
intended
namespace
for
all
following
definitions,
or
insert
it
in
sections
where
a
namespace
switch
is
desired.
syntax
varies
by
implementation,
but
the
standard
behavior
is
to
switch
to
the
existing
package.
Care
should
be
taken
to
ensure
the
target
package
exists
and
is
properly
defined
before
using
in-package.