The package-renaming Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The package-renaming Reference Manual

This is the package-renaming Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Jan 09 15:26:55 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

PACKAGE-RENAMING

This library allows you to locally rename CL packages.


==== Exported Functionality ====

The package-renaming library creates a package PACKAGE-RENAMING,
that exports the following macros and functions:

check-same-package-names
check-package-candidate-names
package-names
find-package-from-names
effect-package-renaming
effect-package-renamings
call-with-effective-package-renamings
with-effective-package-renamings

NB: any kind of package renaming is only safe when package operations
(including any use of the Lisp reader) are single-threaded.


==== Compile-time renaming via ASDF ====

with-effective-package-renamings and call-with-effective-package-renamings
are pretty low-level primitives that let you do what you need,
but require you to do a lot of the groundwork.

First, an important constraint to understand about building CL software.
By intentional design, ASDF only has an :around-compile hook,
but no :around-load hook around load,
or :around-build hook around both compile and load;
indeed, some implementations that rely on linking, such as ECL or GCL,
might not even allow any kind of useful hook around loading,
and some things one might want to do with fasls
(such as linking or concatenating them together into a big fasl)
might preclude any such hook.
Therefore, whatever renamings you do at compile-time
will NOT be done available at load-time.
When the fasl is loaded, only the non-renamed names are available,
and symbols, stored with the principal name of their package at compile-time,
will be resolved against the set of packages at load-time.
This imposes this important constraint on renamings that are admissible
in ASDF's :around-compile hook:
	THE (PRINCIPAL) NAME OF A PACKAGE AS RENAMED AT COMPILE-TIME
	*MUST* BE ONE OF THE NAMES OF THAT PACKAGE AT LOAD-TIME.

For instance, if your target package is COM.FOO.BLAH
and has nicknames CFBLAH and BLAH,
then during your rename, the main name of the package must be one of
COM.FOO.BLAH, CFBLAH or BLAH,
or the symbols will fail to resolve properly at load-time.
You can add as many new local nicknames as you want, and use them locally
in your files, you cannot delete all the original names,
and you must use the original names in any operation that will happen
at runtime or load-time, such as defpackage or find-symbol.

Now, if you want to use package-renaming
to locally override a package A with another B,
it is still possible; but you have to use further tricks.
The trick is to somehow ADD a new unique non-clashing nickname
to each of the packages that are involved in a clash,
at some point after they are defined and before they are used by your code.
For instance, give A the nickname A.at.runtime and B the nickname B.at.runtime.
Then, you can make B.at.runtime the principal name
of whatever renaming you make that targets B,
even with local nickname A,
whereas A is previously renamed away to A.at.runtime.

With this constraint in mind,
a typical way to use package-renaming would be
to use the following in your my-system.asd file:

(defsystem my-system
  :depends-on (:my-system-meta)
  :around-compile "my-system-meta::call-with-renamings"
  ...)

And in B-renaming.asd:
  
(defsystem my-system-meta
  :depends-on (:package-renaming)
  :components ((:file "renamings")))

And in renamings.lisp:

(defpackage :my-system-meta (:use :cl :package-renaming))

(effect-package-renaming
  '((:A (:A :A.regular.nick :A.at.runtime))
    (:B (:B :B.regular.nick :B.at.runtime))))

(defun with-renamings (thunk)
  (call-with-package-renamings
    '((:A :A.at.runtime)
      (:B :B.at.runtime :A :B.other.nick))
    thunk))

That's not all that simple, but at least it's possible.
If you implement an easier all-in-one solution based on this,
I'll happily merge it into this package-renaming.


==== TO DO ====

1- document it

2- write tests

3- document how to use it with ASDF

4- make it work when there are non-trivial overlaps
  between old names and new names

5- write more tests


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 package-renaming

License

MIT

Description

locally renaming packages

Dependency

alexandria

Source

package-renaming.asd (file)

Component

package-renaming.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 package-renaming.asd

Location

package-renaming.asd

Systems

package-renaming (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 package-renaming/package-renaming.lisp

Parent

package-renaming (system)

Location

package-renaming.lisp

Packages

package-renaming

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 package-renaming

Source

package-renaming.lisp (file)

Use List
Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: with-effective-package-renamings PACKAGE-RENAMINGS &body BODY

Evaluate the BODY in an dynamic environment where
the PACKAGE-RENAMINGS have been effected by effect-package-renamings,
and are undone in the end by the same
using the reverse renamings returned by the first call.
PACKAGE-RENAMINGS is a compile-time constant;
for runtime-computed renamings, use the call-with-effective-package-renamings function.

Package

package-renaming

Source

package-renaming.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: call-with-effective-package-renamings PACKAGE-RENAMINGS THUNK &key IF-DOES-NOT-EXIST

Call the THUNK in an dynamic environment where
the PACKAGE-RENAMINGS have been effected by effect-package-renamings, and are undone in the end by the same
using the reverse renamings returned by the first call.

Package

package-renaming

Source

package-renaming.lisp (file)

Function: check-package-candidate-names PACKAGE-DESIGNATOR NAMES

Check that each of the NAMES either designates the package specified by PACKAGE-DESIGNATOR or no package at all

Package

package-renaming

Source

package-renaming.lisp (file)

Function: check-same-package-names NAMES

Check that the NAMES all designate the same package

Package

package-renaming

Source

package-renaming.lisp (file)

Function: effect-package-renaming OLD NEW &key IF-DOES-NOT-EXIST

Effect the renaming of a package with OLD names (designator or list of designators) to NEW names (a designator or list of designators).
Return the list of actual names that the package had.
IF-DOES-NOT-EXIST may be NIL or ERROR.

Package

package-renaming

Source

package-renaming.lisp (file)

Function: effect-package-renamings PACKAGE-RENAMINGS &key IF-DOES-NOT-EXIST

Call effect-package-renaming on each renaming. Return a list of reverse renamings to undo the thing. IF-DOES-NOT-EXIST may be NIL or ERROR;
in the former case, the reverse renaming will rename the possibly newly created package to the "old" name.

Package

package-renaming

Source

package-renaming.lisp (file)

Function: find-package-from-names NAMES &key IF-DOES-NOT-EXIST

Find the first package designated by one of the NAMES. IF-DOES-NOT-EXIST may be NIL or ERROR.

Package

package-renaming

Source

package-renaming.lisp (file)

Function: package-names PACKAGE-DESIGNATOR

List of the designated package’s name and nicknames

Package

package-renaming

Source

package-renaming.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   P  
Index Entry  Section

F
File, Lisp, package-renaming.asd: The package-renaming<dot>asd file
File, Lisp, package-renaming/package-renaming.lisp: The package-renaming/package-renaming<dot>lisp file

L
Lisp File, package-renaming.asd: The package-renaming<dot>asd file
Lisp File, package-renaming/package-renaming.lisp: The package-renaming/package-renaming<dot>lisp file

P
package-renaming.asd: The package-renaming<dot>asd file
package-renaming/package-renaming.lisp: The package-renaming/package-renaming<dot>lisp file

Jump to:   F   L   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   E   F   M   P   W  
Index Entry  Section

C
call-with-effective-package-renamings: Exported functions
check-package-candidate-names: Exported functions
check-same-package-names: Exported functions

E
effect-package-renaming: Exported functions
effect-package-renamings: Exported functions

F
find-package-from-names: Exported functions
Function, call-with-effective-package-renamings: Exported functions
Function, check-package-candidate-names: Exported functions
Function, check-same-package-names: Exported functions
Function, effect-package-renaming: Exported functions
Function, effect-package-renamings: Exported functions
Function, find-package-from-names: Exported functions
Function, package-names: Exported functions

M
Macro, with-effective-package-renamings: Exported macros

P
package-names: Exported functions

W
with-effective-package-renamings: Exported macros

Jump to:   C   E   F   M   P   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
Package, package-renaming: The package-renaming package
package-renaming: The package-renaming system
package-renaming: The package-renaming package

S
System, package-renaming: The package-renaming system

Jump to:   P   S