FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version


Arguments: object &optional type

This function returns the source file for object if such information is available and returns nil otherwise.

object identifies the object for which source-file information is desired. type, if provided, may be a symbol, a list or t. The behavior of source-file depends on the value of type. If type is not provided, and there is a single source file defining object, the pathname of that file is returned. If there is no source file information, nil is returned. If there are different source files in which are different types of definitions related to object, a continuable error is signaled and specific type information is requested if one continues from the error.

type may be any symbol, a list of symbols, or t. If unspecified, :function and :macro are tried (i.e., if object is or names a macro, type defaults to :macro, otherwise it defaults to :function).

The predefined symbols are :function, :macro, :operator, and :variable.

:function is used for functions, generic functions and methods, flavor methods, and defstruct accessors.

:macro is used for macros.

:operator is used for any type of operator (sort of a union of :function and :macro).

:variable is used for variables and constants.

Those are the only objects for which source file information is automatically recorded. If type is one of these symbols, the pathname of the relevant source file is returned if the information exists, and nil if it does not exist. If there is no object of the specified type identified by object, an error is signaled.

For example, if foo is a function (and has no other definitions recorded),

(source-file 'foo :function)


(source-file 'foo)

both return the pathname of the source file, if it is known, and nil if it is not known, but

(source-file 'foo :macro)

will signal an error.

Note: there may be several source files defining generic functions and methods named by a symbol. All of these files are remembered, but only the latest one is printed by

(source-file 'foo :function)


(source-file 'foo)


(source-file 'foo t)

prints a list of dotted pairs identifying all files where something named by foo is defined, including the file with the defgeneric (if there is one) and all files containing defmethod's.

If type is a list of allowable types, a list of dotted pairs of the form

(type . pathname)

is returned with a pair for each type for which a source file can be found. If no source files can be found, nil is returned. No error is signaled even if object is neither a macro nor a function.

If type is t, again a list of dotted pairs is returned with pairs for each of the allowable types for which a source file is known. No error is signaled if no source file is known for a given type.

setf can be used to record source file information manually, in which case the type must be given and be a symbol.

Note that the value of *source-pathname* is a string, while source-file returns a pathname. The pathname is simply generated by calling the pathname function with the string as an argument.

The source file for a definition typed to the top-level is the keyword :top-level.

See also source-file-recording.htm for general information on source file recording in Allegro CL.

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 9.0 page.
Created 2015.5.21.

Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version