aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-04-19 00:17:47 +0000
committerRichard M. Stallman2002-04-19 00:17:47 +0000
commitf9350c5cef62b9b89f1b93b62c9c20c8c46e4dee (patch)
tree9335270f342651888dca195208f2b46d205aae3b
parent11713b6dafb4f63fa246c6de77133ed8ec80243a (diff)
downloademacs-f9350c5cef62b9b89f1b93b62c9c20c8c46e4dee.tar.gz
emacs-f9350c5cef62b9b89f1b93b62c9c20c8c46e4dee.zip
Explain use of `declare'.
-rw-r--r--lispref/edebug.texi48
1 files changed, 30 insertions, 18 deletions
diff --git a/lispref/edebug.texi b/lispref/edebug.texi
index 7e1099be236..7df8a7f2c55 100644
--- a/lispref/edebug.texi
+++ b/lispref/edebug.texi
@@ -1063,32 +1063,44 @@ macro call are forms to be evaluated. (Evaluation may occur explicitly
1063in the macro body, or when the resulting expansion is evaluated, or any 1063in the macro body, or when the resulting expansion is evaluated, or any
1064time later.) 1064time later.)
1065 1065
1066 Therefore, you must define an Edebug specification for each macro that 1066 Therefore, you must define an Edebug specification for each macro
1067Edebug will encounter, to explain the format of calls to that macro. To 1067that Edebug will encounter, to explain the format of calls to that
1068do this, use @code{def-edebug-spec}. 1068macro. To do this, add an @code{edebug} declaration to the macro
1069definition. Here is a simple example that shows the specification for
1070the @code{for} example macro (@pxref{Argument Evaluation}).
1071
1072@example
1073(defmacro for (var from init to final do &rest body)
1074 "Execute a simple \"for\" loop.
1075For example, (for i from 1 to 10 do (print i))."
1076 (declare (edebug symbolp "from" form "to" form "do" &rest form))
1077 ...)
1078@end example
1079
1080@defspec declare (edebug @var{specification})
1081Specify which expressions of a call to the macro in which the
1082declaration appears are forms to be evaluated. For simple macros, the
1083@var{specification} often looks very similar to the formal argument list
1084of the macro definition, but specifications are much more general than
1085macro arguments.
1086@end defspec
1087
1088You can also define an edebug specification for a macro separately
1089from the macro definition with @code{def-edebug-spec}. Adding
1090@code{edebug} declarations is preferred, and more convenient, for
1091macro definitions in Lisp, but @code{def-edebug-spec} makes it
1092possible to define Edebug specifications for special forms implemented
1093in C.
1069 1094
1070@deffn Macro def-edebug-spec macro specification 1095@deffn Macro def-edebug-spec macro specification
1071Specify which expressions of a call to macro @var{macro} are forms to be 1096Specify which expressions of a call to macro @var{macro} are forms to be
1072evaluated. For simple macros, the @var{specification} often looks very 1097evaluated. @var{specification} should be the edebug specification.
1073similar to the formal argument list of the macro definition, but 1098It is not evaluated.
1074specifications are much more general than macro arguments.
1075 1099
1076The @var{macro} argument can actually be any symbol, not just a macro 1100The @var{macro} argument can actually be any symbol, not just a macro
1077name. 1101name.
1078@end deffn 1102@end deffn
1079 1103
1080Here is a simple example that defines the specification for the
1081@code{for} example macro (@pxref{Argument Evaluation}), followed by an
1082alternative, equivalent specification.
1083
1084@example
1085(def-edebug-spec for
1086 (symbolp "from" form "to" form "do" &rest form))
1087
1088(def-edebug-spec for
1089 (symbolp ['from form] ['to form] ['do body]))
1090@end example
1091
1092Here is a table of the possibilities for @var{specification} and how each 1104Here is a table of the possibilities for @var{specification} and how each
1093directs processing of arguments. 1105directs processing of arguments.
1094 1106