6.2 The Source File Recording Facility

6.2.3 Reference pages

discard-source-file-info Function

Syntax:discard-source-file-info

The functiondiscard-source-file-info discards all recorded source file information. This function allows you to reduce the size of an image; it is particularly useful before an image is saved.

Usingdiscard-source-file-info does not affect the setting of*record-source-files*.

See Also: record-source-file, *record-source-files*

get-source-file Function

Syntax:get-source-file object&optional type want-list

The functionget-source-file returns information about the file or files in which the specified object is defined.

The optional type argument is a symbol that identifies the type of definition sought. If this argument is non-nil, its value can be eitherfunction,macro,structure, or a definition type that you have created by using the functionrecord-source-file.

If you specify the type argument,get-source-file searches for only a specific type of definition. If the definition exists, the pathname of the source file that contains the definition is returned. If the definition does not exist, an error is signaled.

If the value of the type argument isnil and you specify the want-list argument, the function searches for all definitions of the specified object and returns a list of the form(type . pathname) for each definition of the object.

If you do not specify the type or the want-list argument,get-source-file searches for all definitions of the specified object. If there is a single definition of the object, the function returns two values: the pathname of the file that contains the definition and the type of definition. If there are multiple definitions of the same object, a continuable error is signaled.

See Also: record-source-file

*load-pathname* Variable

Syntax:*load-pathname*

The variable*load-pathname* contains the pathname that is returned by the function load whenever it loads a file.

The functionload rebinds this variable every time a file is loaded. During the dynamic extent of the loading process, evaluations can access this variable to find out what file they are being loaded from. The information is provided for both binary and source files.

record-source-file Function

Syntax:record-source-file object type&optional pathname load-instance

The functionrecord-source-file records information about the source file that defines the specified object.

The type argument is a symbol that identifies the type of definition. The value of type can be eitherfunction,macro,structure, or a definition type you create by supplying a symbol.

The optional pathname argument gives the pathname of the file that is defining the object. The default pathname is the value of the variable*source-pathname*.

The value of the optional load-instance argument is an object that distinguishes the current instance of loading a file from other instances of loading the same file. You can use the load-instance argument to detect multiple definitions of the same object in the same file.

See Also: *redefinition-action*, *source-pathname*

*record-source-files* Variable

Syntax:*record-source-files*

The variable*record-source-files* determines whether to record the name of the file in which an object is defined.

If the variable has a non-nil value, source file names are recorded. Redefinition warnings are produced only when an object is redefined in the same file. The warnings include the name of the original source file that defines the object. The value of this variable is non-nil by default.

If the value of this variable isnil, source file names are not recorded; however, old information about an object is not lost. Redefinition warnings are produced when a file is reloaded and when an object is redefined in the same file; they do not include source file information.

See Also: record-source-file, *redefinition-action*

*redefinition-action* Variable

Syntax:*redefinition-action*

The variable*redefinition-action* specifies what action is taken when a redefinition occurs.

This variable can have one of the following values:

;;; Suppose that *record-source-files* is set to :warn, which is
;;; the default.  If the file temp1.lisp contains 
;;;                         (defun test ()) 
;;; and the file temp2.lisp also contains 
;;;                         (defun test ())
;;; the following session could occur:
;; The default action is :warn.
> *redefinition-action*	 
:WARN

;; Define "test" the first time. > (load "~/temp1.lisp") ;;; Loading source file "/u/kdo/temp1.lisp" #P"/u/kdo/temp1.lisp"

;; Redefine from same file--no message. > (load "~/temp1.lisp") ;;; Loading source file "/u/kdo/temp1.lisp" #P"/u/kdo/temp1.lisp" ;; Redefine it by loading a new file. > (load "~/temp2.lisp") ;;; Loading source file "/u/kdo/temp2.lisp" ;;; Warning: Redefining function TEST which used to be defined in ;;; file /u/kdo/temp1.lisp #P"/u/kdo/temp2.lisp"

;; Redefine it from the top level. > (defun test ()) ;;; Warning: Redefining function TEST which used to be defined in ;;; file /u/kdo/temp2.lisp TEST

;; Reset to ask for confirmation. > (setq *redefinition-action* :query) :QUERY > (load "~/temp1.lisp") ;;; Loading source file "/u/kdo/temp1.lisp" Redefining function TEST which used to be defined at top level OK? (Y or N) y #P"/u/kdo/temp1.lisp"

;; Do not print warnings. > (setq *redefinition-action* nil) NIL

> (load "~/temp2.lisp") ;;; Loading source file "/u/kdo/temp2.lisp" #P"/u/kdo/temp2.lisp"

*source-pathname* Variable

Syntax:*source-pathname*

The variable*source-pathname* contains the truename of the source file of the file being loaded. If a source file is loaded, the value of this variable is the truename of that file. If a compiled file is loaded, the value of this variable is the truename of the source file from which the compiled file was created. You can bind this variable to another value if you do not want the truename of the file being loaded to be used as the default pathname for record-source-file.

See Also: record-source-file

*terse-redefinitions* Variable

Syntax:*terse-redefinitions*

The variable*terse-redefinitions* controls the level of detail printed in redefinition warnings.

The default value of this variable isnil.

If the variable has a non-nil value, the warnings are brief and can be hard to understand.

See Also: *redefinition-action*


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker