Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE

This package implements the Common Lisp package system. <Xach> The basic idea of that file is that the semantics of the CL package system can be implemented by an object with three special kinds of tables (present-table, shadowing-table, external-table) and two lists (used-packs, used-by-packs). The rest is implementation. It shadows the CL symbols dealing with packages, and exports replacements that implement the package system anew. Additionnal symbol exported: PACKAGE-EXISTS-ERROR PACKAGE-DOES-NOT-EXIST-ERROR SYMBOL-CONFLICT-ERROR SYMBOL-CONFLICT-EXISTING-SYMBOL SYMBOL-CONFLICT-IMPORTED-SYMBOL PACKAGE-DOCUMENTATION License: BSD Copyright (c) 2012 Zachary Beane <xach@xach.com>, All Rights Reserved Copyright (c) 2012 Pascal Bourguignon <pjb@informatimago.com>, All Rights Reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README:

FUNCTION

Public

LIST-ALL-PACKAGES

RETURN: A fresh list of all registered packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_list_a.htm>

Private

MIXED-CASE-P (STRING)

Whether the string contains both lower case and upper case letters.

NEEDS-ESCAPE-P (SYMBOL-NAME)

Whether the symbol name needs to be escaped.

NORMALIZE-PACKAGE-DESIGNATOR (OBJECT &KEY (IF-PACKAGE-DOES-NOT-EXIST STRING) (IF-PACKAGE-EXISTS PACKAGE) (IF-NOT-A-PACKAGE-DESIGNATOR ERROR))

Normalize the given PACKAGE-DESIGNATOR. Objects of type PACKAGE-DESIGNATOR are either PACKAGE or objects of type STRING-DESIGNATOR. RETURN: either NIL, a STRING designating a non-existent package, or an existing PACKAGE. IF-NOT-A-PACKAGE-DESIGNATOR The default is :ERROR. NIL If the OBJECT is not a PACKAGE-DESIGNATOR then return NIL. :ERROR If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR. :IGNORE If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR, with an IGNORE restart that when chosen returns NIL. :REPLACE If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR, with a replace restart that when chosen let the user input another PACKAGE-DESIGNATOR. :IGNORE-OR-REPLACE If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR, with the two previous restarts. If the object is a PACKAGE-DESIGNATOR, then the results depends on the following parameters and whether the designated package exists or not. IF-PACKAGE-DOES-NOT-EXIST The default is :STRING NIL If the OBJECT designates a PACKAGE that doesn't exist then return NIL. :STRING If the OBJECT designates a PACKAGE that doesn't exist then (it would be a STRING-DESIGNATOR) return the designated STRING. :ERROR If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR. :IGNORE If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR with an IGNORE restart that when chosen returns NIL. :REPLACE If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR with a replace restart that when chosen let the user input another PACKAGE-DESIGNATOR. :IGNORE-OR-REPLACE If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR with the two previous restarts. IF-PACKAGE-EXISTS The default is :PACKAGE :PACKAGE If the OBJECT designates a PACKAGE that does exist then return the designated PACKAGE. :STRING If the OBJECT designates a PACKAGE that does exist then return the designated package name. :ERROR If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR. :IGNORE If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR with an IGNORE restart that when chosen returns NIL. :REPLACE If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR with a replace restart that when chosen let the user input another PACKAGE-DESIGNATOR. :IGNORE-OR-REPLACE If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR with the two previous restarts.

Undocumented

%DEFINE-PACKAGE (NAME SHADOWS SHADOWING-IMPORTS USES IMPORTS INTERNS EXPORTS DOCUMENTATION NICKNAMES)

BODY (BODY)

CHECK-DISJOINTS (SHADOWS SHADOWING-IMPORT-FROMS IMPORT-FROMS INTERNS EXPORTS)

CHECK-NEW-NAMES (PACK-NAME NICKNAMES &KEY RENAMING-PACKAGE)

CLASSIFY-PER-PACKAGE (SYMBOLS)

CONSTITUENTP (CH FIRST-CHARACTER-P &OPTIONAL (READTABLE *READTABLE*))

DECLARATIONS (BODY)

ENSURE-LIST (OBJECT)

GENERATE-DO-SYMBOLS-LOOP (VAR PACKAGE RESULT-FORM BODY SYMBOL-TYPES)

MAKE-PACKAGE-ITERATOR (PACKAGES SYMBOL-TYPES)

NORMALIZE-STRING-DESIGNATOR (OBJECT &KEY (IF-NOT-A-STRING-DESIGNATOR ERROR))

NORMALIZE-WEAK-DESIGNATOR-OF-LIST-OF-STRING-DESIGNATOR (OBJECT)

PARSES-AS-A-NUMBER-P (STRING &KEY (START 0) (END NIL) (BASE *READ-BASE*))

PREPARE-SYMBOL-NAME (SNAME)

QUERY-PACKAGE-NAME

QUERY-PACKAGE-NICKNAME

QUERY-STRING

QUERY-SYMBOL

SPECIALP (CH &OPTIONAL (READTABLE *READTABLE*))

MACRO

Public

DEFPACKAGE (DEFINED-PACKAGE-NAME &REST OPTIONS)

DO: Define a new package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_defpkg.htm>

DO-ALL-SYMBOLS ((VAR &OPTIONAL RESULT-FORM) &BODY BODY)

DO: Iterate over all the symbols of all the packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm>

DO-EXTERNAL-SYMBOLS ((VAR &OPTIONAL PACKAGE RESULT-FORM) &BODY BODY)

DO: Iterate over all the external symbols of the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm>

DO-SYMBOLS ((VAR &OPTIONAL PACKAGE RESULT-FORM) &BODY BODY)

DO: Iterate over all the symbols of the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm>

IN-PACKAGE (NAME)

DO: Sets the current *package* to the package designated by NAME. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_in_pkg.htm>

WITH-PACKAGE-ITERATOR ((NAME PACKAGE-LIST-FORM &REST SYMBOL-TYPES) &BODY DECLARATIONS-BODY)

DO: Within the lexical scope of the body forms, the name is defined via macrolet such that successive invocations of (name) will return the symbols, one by one, from the packages in package-list. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_w_pkg_.htm>

Private

APPENDF (PLACE &REST ARGS &ENVIRONMENT ENV)

Append onto list

Undocumented

DEFINE-NORMALIZE-PACKAGE-METHODS (NAME &KEY (IF-PACKAGE-DOES-NOT-EXIST REPLACE) (TYPE-ERROR NIL))

ZDO-EXTERNAL-SYMBOLS ((VAR PACK) &BODY BODY)

GENERIC-FUNCTION

Public

BOUNDP (OBJECT)

RETURN: Whether the symbol is bound to a value. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_boundp.htm>

DELETE-PACKAGE (PACK-NAME)

DO: Delete the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_del_pk.htm>

EXPORT (SYM &OPTIONAL PACK)

DO: Export the designated symbols from the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_export.htm>

FBOUNDP (OBJECT)

RETURN: Whether the symbol is fbound to a function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_fbound.htm>

FIND-ALL-SYMBOLS (NAME)

RETURN: The list of all symbols named NAME in all packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_find_a.htm>

FIND-PACKAGE (PACK-NAME)

RETURN: The package designated by PACK-NAME, or NIL if none. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_find_p.htm>

FIND-SYMBOL (SYM-NAME &OPTIONAL PACK)

RETURN: the symbol named SYM-NAME in the package PACK, if found and a status keyword. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_find_s.htm>

IMPORT (SYMBOLS &OPTIONAL PACK)

DO: Import the symbols into the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_import.htm>

INTERN (SYM-NAME &OPTIONAL PACK)

DO: Intern the symbol name in the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_intern.htm>

KEYWORDP (OBJECT)

RETURN: Whether the object is a keyword. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_kwdp.htm>

MAKE-PACKAGE (PACK-NAME &KEY NICKNAMES USE (NICKNAMES 'NIL) (USE 'NIL))

DO: Make a new package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_pkg.htm>

MAKE-SYMBOL (SYM-NAME)

DO: Make a new symbol URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_sym.htm>

PACKAGE-ERROR-PACKAGE (PACKAGE-ERROR)

RETURN: The package in error. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_er.htm>

PACKAGE-SHADOWING-SYMBOLS (PACK)

RETURN: The list of shadowing symbols of the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_sh.htm>

PACKAGEP (PACKAGE)

RETURN: Whether the object is a package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkgp.htm>

RENAME-PACKAGE (PACKAGE NEW-NAME &OPTIONAL NEW-NICKNAMES)

DO: Rename the package giving it the NEW-NAME and NEW-NICKNAMES. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rn_pkg.htm>

SHADOW (SYMBOL-NAMES &OPTIONAL PACK)

DO: Shadow the designated symbols. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_shadow.htm>

SHADOWING-IMPORT (SYMBOLS &OPTIONAL PACK)

DO: Shadow and import the designated symbols. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_shdw_i.htm>

SYMBOL-CONFLICT-EXISTING-SYMBOL (ERROR)

RETURN: The existing symbol in conflict.

SYMBOL-CONFLICT-IMPORTED-SYMBOL (ERROR)

RETURN: The imported symbol in conflict.

SYMBOLP (OBJECT)

RETURN: Whether the object is a symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symbol.htm>

UNEXPORT (SYM &OPTIONAL PACK)

DO: Unexport the designated symbols from the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_unexpo.htm>

UNINTERN (SYM &OPTIONAL PACK)

DO: Unintern the designated symbols from the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_uninte.htm>

UNUSE-PACKAGE (PACK &OPTIONAL USING-PACK)

DO: Make the USING-PACK unuse the package PACK URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_unuse_.htm>

USE-PACKAGE (PACK &OPTIONAL USING-PACK)

DO: Make the USING-PACK use the package PACK. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_use_pk.htm>

Private

Undocumented

ACCESSIBLEP (SYM PACK)

CHECK-EXPORT-CONFLICT (SYM PACK)

CHECK-IMPORT-CONFLICT (SYM PACK)

CHECK-INHERIT-CONFLICT (USED-PACK USING-PACK)

CHECK-UNINTERN-CONFLICT (SYM-NAME PACK)

EXTERNALP (SYM PACK)

FORMAT-ARGUMENTS (CONDITION)

FORMAT-CONTROL (CONDITION)

MAKE-CONSTANT (SYMBOL VALUE)

MAKE-SYM-TABLE

PACKAGE-EXPORT-LIST (PACKAGE)

PACKAGE-IMPORT-FROM-LIST (PACKAGE)

PACKAGE-SHADOW-LIST (PACKAGE)

PACKAGE-SHADOWING-IMPORT-LIST (PACKAGE)

PACKAGE-SYMBOLS (PACKAGE)

PRESENTP (SYM PACK)

SHADOWINGP (SYM PACK)

SYMBOL-DOES-NOT-EXIST-SYMBOL-NAME (CONDITION)

SYMBOL-INACCESSIBLE-SYMBOL (CONDITION)

TGET (SYM-NAME TABLE)

TMAP-SYMS (FUN TABLE)

TMEMBER (SYM TABLE)

TMEMBERS (TABLE)

TPUT (SYM TABLE)

TREMOVE (SYM TABLE)

ZIMPORT-WITHOUT-CHECKS (SYM PACK)

ZUNINTERN-WITHOUT-CHECKS (SYM PACK)

SLOT-ACCESSOR

Public

PACKAGE-DOCUMENTATION (PACKAGE)

The RETURN: The documentation string of the package.

SETFPACKAGE-DOCUMENTATION (NEW-VALUE OBJECT)

Set the RETURN: The documentation string of the package.

PACKAGE-NAME (PACK)

The RETURN: The package name. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_na.htm>

PACKAGE-NICKNAMES (PACKAGE)

The RETURN: The list of nicknames of the package.

PACKAGE-USE-LIST (PACK)

The RETURN: The list of packages used by PACK. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_us.htm>

PACKAGE-USED-BY-LIST (PACK)

The RETURN: The list of packages that use PACK. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg__1.htm>

SYMBOL-FUNCTION (SYMBOL)

The RETURN: The function of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_1.htm>

SETFSYMBOL-FUNCTION (NEW-VALUE OBJECT)

Set the RETURN: The function of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_1.htm>

SYMBOL-NAME (SYM)

The RETURN: the name of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_2.htm>

SYMBOL-PACKAGE (SYM)

The RETURN: the home package of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_3.htm>

SYMBOL-PLIST (SYMBOL)

The RETURN: The plist of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_4.htm>

SETFSYMBOL-PLIST (NEW-VALUE OBJECT)

Set the RETURN: The plist of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_4.htm>

SYMBOL-VALUE (SYMBOL)

The RETURN: The value of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_5.htm>

SETFSYMBOL-VALUE (NEW-VALUE OBJECT)

Set the RETURN: The value of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_5.htm>

Private

Undocumented

EXTERNAL-TABLE (PACK)

SETFNAME (NEW-VALUE OBJECT)

NAME-TABLE (OBJECT)

SETFNICKNAMES (NEW-VALUE OBJECT)

PRESENT-TABLE (PACK)

SHADOWING-TABLE (PACK)

SYM-PACK (SYM)

SETFSYM-PACK (PACK SYM)

SYMBOL-CONSTANTP (OBJECT)

SETFSYMBOL-CONSTANTP (NEW-VALUE OBJECT)

SETFUSED-BY-PACKS (USED-BY-PACKS PACK)

SETFUSED-PACKS (USED-PACKS PACK)

VARIABLE

Public

*PACKAGE*

The current package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_pkg.htm>

Private

Undocumented

*COMMON-LISP-PACKAGE*

*COMMON-LISP-USER-PACKAGE*

*KEYWORD-PACKAGE*

*PACKS*

CLASS

Public

KEYWORD

The keyword class. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_kwd.htm>

PACKAGE

The package class. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_pkg.htm>

SYMBOL

The symbol class. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_symbol.htm>

Private

Undocumented

SYM-TABLE

CONDITION

Public

PACKAGE-DOES-NOT-EXIST-ERROR

The error condition signaling that no package with that name exists.

PACKAGE-ERROR

The type package-error consists of error conditions related to operations on packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/e_pkg_er.htm>

PACKAGE-EXISTS-ERROR

The error condition signaling that a package with the same name already exists.

SYMBOL-CONFLICT-ERROR

The error condition signaling a symbol conflict.

Private

Undocumented

SIMPLE-ERROR-MIXIN

SIMPLE-PACKAGE-ERROR

SIMPLE-PROGRAM-ERROR

SIMPLE-TYPE-ERROR

SYMBOL-DOES-NOT-EXIST-ERROR

SYMBOL-INACCESSIBLE-ERROR