Function provide, require

Syntax:

provide module-name implementation-dependent

"pathname" => "pathname list" per X3J13. -kmp 05-Oct-93

require module-name &optional pathname-list implementation-dependent

Arguments and Values:

KMP: Maybe should be "module name designator"? Oh well. This is the only use, so leave it for now.module-name—a string designator.

pathname-listnil, or a designator for a non-empty list of pathname designators. The default is nil.

Description:

11.8.0 4provide adds the module-name to the list held by *modules*, if such a name is not already present.

11.8.0 5require tests for the presence of the module-name in the list held by *modules*. If it is present, require immediately returns. Otherwise, an attempt is made to load an appropriate set of files as follows: The pathname-list argument, if non-nil, specifies a list of pathnames to be loaded in order, from left to right. If the pathname-list is nil, an implementation-dependent mechanism will be invoked in an attempt to load the module named module-name; if no such module can be loaded, an error of type error is signaled.

Both functions use string= to test for the presence of a module-name.

Examples:

11.8.0 6 (CLtL Table 11-1: An Initialization File) \code ;;;; New and improved lisp init file for I. Newton ;;; Set up the CL-USER package the way I like it. (require "CALCULUS") ; I use CALCULUS a lot. Load it. (use-package "CALCULUS") ; Get easy access to exported symbols. (require "NEWTONIAN-MECHANICS") ;Ditto for NEWTONIAN-MECHANICS (use-package "NEWTONIAN-MECHANICS") ;;; Ignore that Relativity stuff until they've got it debugged better. ;(require "RELATIVITY") ;;; These are worth loading, but I'll use qualified names, such ;;; as PHLOGISTON:MAKE-FIRE-BOTTLE, to get any symbols I might need. (require "PHLOGISTON") (require "ALCHEMY") (provide "NEWTON-PERSONAL-PREFERENCES") \endcode

;;; This illustrates a nonportable use of REQUIRE, because it
;;; depends on the implementation-dependent file-loading mechanism.

(require "CALCULUS")

;;; This use of REQUIRE is nonportable because of the literal 
;;; physical pathname.  

(require "CALCULUS" "/usr/lib/lisp/calculus")

;;; One form of portable usage involves supplying a logical pathname,
;;; with appropriate translations defined elsewhere.

(require "CALCULUS" "lib:calculus")

;;; Another form of portable usage involves using a variable or
;;; table lookup function to determine the pathname, which again
;;; must be initialized elsewhere.

(require "CALCULUS" *calculus-module-pathname*)

Side Effects:

provide modifies *modules*.

Affected By:

The specific action taken by require is affected by calls to provide (or, in general, any changes to the value of *modules*).

Exceptional Situations:

Should signal an error of type type-error if module-name is not a string designator.

If require fails to perform the requested operation due to a problem while interacting with the file system, an error of type file-error is signaled.

An error of type file-error might be signaled if any pathname in pathname-list is a designator for a wild pathname.

See Also:

*modules*, Section 19.1.2 (Pathnames as Filenames)

Notes:

deprecation note was missing --sjl 4 Mar 92The functions provide and require are deprecated.

11.8.0 3If a module consists of a single package, it is customary for the package and module names to be the same.