diff options
| author | Richard M. Stallman | 2002-04-19 00:17:47 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-04-19 00:17:47 +0000 |
| commit | f9350c5cef62b9b89f1b93b62c9c20c8c46e4dee (patch) | |
| tree | 9335270f342651888dca195208f2b46d205aae3b | |
| parent | 11713b6dafb4f63fa246c6de77133ed8ec80243a (diff) | |
| download | emacs-f9350c5cef62b9b89f1b93b62c9c20c8c46e4dee.tar.gz emacs-f9350c5cef62b9b89f1b93b62c9c20c8c46e4dee.zip | |
Explain use of `declare'.
| -rw-r--r-- | lispref/edebug.texi | 48 |
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 | |||
| 1063 | in the macro body, or when the resulting expansion is evaluated, or any | 1063 | in the macro body, or when the resulting expansion is evaluated, or any |
| 1064 | time later.) | 1064 | time 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 |
| 1067 | Edebug will encounter, to explain the format of calls to that macro. To | 1067 | that Edebug will encounter, to explain the format of calls to that |
| 1068 | do this, use @code{def-edebug-spec}. | 1068 | macro. To do this, add an @code{edebug} declaration to the macro |
| 1069 | definition. Here is a simple example that shows the specification for | ||
| 1070 | the @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. | ||
| 1075 | For 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}) | ||
| 1081 | Specify which expressions of a call to the macro in which the | ||
| 1082 | declaration appears are forms to be evaluated. For simple macros, the | ||
| 1083 | @var{specification} often looks very similar to the formal argument list | ||
| 1084 | of the macro definition, but specifications are much more general than | ||
| 1085 | macro arguments. | ||
| 1086 | @end defspec | ||
| 1087 | |||
| 1088 | You can also define an edebug specification for a macro separately | ||
| 1089 | from the macro definition with @code{def-edebug-spec}. Adding | ||
| 1090 | @code{edebug} declarations is preferred, and more convenient, for | ||
| 1091 | macro definitions in Lisp, but @code{def-edebug-spec} makes it | ||
| 1092 | possible to define Edebug specifications for special forms implemented | ||
| 1093 | in C. | ||
| 1069 | 1094 | ||
| 1070 | @deffn Macro def-edebug-spec macro specification | 1095 | @deffn Macro def-edebug-spec macro specification |
| 1071 | Specify which expressions of a call to macro @var{macro} are forms to be | 1096 | Specify which expressions of a call to macro @var{macro} are forms to be |
| 1072 | evaluated. For simple macros, the @var{specification} often looks very | 1097 | evaluated. @var{specification} should be the edebug specification. |
| 1073 | similar to the formal argument list of the macro definition, but | 1098 | It is not evaluated. |
| 1074 | specifications are much more general than macro arguments. | ||
| 1075 | 1099 | ||
| 1076 | The @var{macro} argument can actually be any symbol, not just a macro | 1100 | The @var{macro} argument can actually be any symbol, not just a macro |
| 1077 | name. | 1101 | name. |
| 1078 | @end deffn | 1102 | @end deffn |
| 1079 | 1103 | ||
| 1080 | Here is a simple example that defines the specification for the | ||
| 1081 | @code{for} example macro (@pxref{Argument Evaluation}), followed by an | ||
| 1082 | alternative, 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 | |||
| 1092 | Here is a table of the possibilities for @var{specification} and how each | 1104 | Here is a table of the possibilities for @var{specification} and how each |
| 1093 | directs processing of arguments. | 1105 | directs processing of arguments. |
| 1094 | 1106 | ||