Next: Creating Symbols Prev: Symbol Components Up: Symbols
A "definition" in Lisp is a special form that announces your
intention to use a certain symbol in a particular way. In Emacs Lisp,
you can define a symbol as a variable, or define it as a function (or
macro), or both independently.
A definition construct typically specifies a value or meaning for the
symbol for one kind of use, plus documentation for its meaning when used
in this way. Thus, when you define a symbol as a variable, you can
supply an initial value for the variable, plus documentation for the
`defvar' and `defconst' are special forms that define a symbol as a
global variable. They are documented in detail in Note: Defining
`defun' defines a symbol as a function, creating a lambda expression
and storing it in the function cell of the symbol. This lambda
expression thus becomes the function definition of the symbol. (The
term "function definition", meaning the contents of the function cell,
is derived from the idea that `defun' gives the symbol its definition
as a function.) Note: Functions.
`defmacro' defines a symbol as a macro. It creates a macro object
and stores it in the function cell of the symbol. Note that a given
symbol can be a macro or a function, but not both at once, because both
macro and function definitions are kept in the function cell, and that
cell can hold only one Lisp object at any given time. Note: Macros.
In GNU Emacs Lisp, a definition is not required in order to use a
symbol as a variable or function. Thus, you can make a symbol a global
variable with `setq', whether you define it first or not. The real
purpose of definitions is to guide programmers and programming tools.
They inform programmers who read the code that certain symbols are
*intended* to be used as variables, or as functions. In addition,
utilities such as `etags' and `make-docfile' can recognize definitions,
and add the appropriate information to tag tables and the
`emacs/etc/DOC-VERSION' file. Note: Accessing Documentation.
automatically generated by info2www