diff options
| author | Eric Abrahamsen | 2017-12-14 12:59:07 -0800 |
|---|---|---|
| committer | Eric Abrahamsen | 2017-12-14 12:59:07 -0800 |
| commit | 94b52207cf0bd25d3e8052b01bda945e8718bd12 (patch) | |
| tree | c2ebe43c25adfd08dfbde36210a3db01599b987b | |
| parent | 8e13d3ab1a31c3f5aee19ee7a92ddaed5fc3eb2d (diff) | |
| download | emacs-94b52207cf0bd25d3e8052b01bda945e8718bd12.tar.gz emacs-94b52207cf0bd25d3e8052b01bda945e8718bd12.zip | |
Clarify manual section on &context specializer for methods
* doc/lispref/functions.texi (Generic Functions): Provide a little
more information on how they work.
| -rw-r--r-- | doc/lispref/functions.texi | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 466a12f7a48..d84f09d8462 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi | |||
| @@ -1225,7 +1225,7 @@ This form defines a method like @code{cl-defmethod} does. | |||
| 1225 | @end table | 1225 | @end table |
| 1226 | @end defmac | 1226 | @end defmac |
| 1227 | 1227 | ||
| 1228 | @defmac cl-defmethod name [qualifier] arguments &rest [docstring] body | 1228 | @defmac cl-defmethod name [qualifier] arguments [&context (expr spec)@dots{}] &rest [docstring] body |
| 1229 | This macro defines a particular implementation for the generic | 1229 | This macro defines a particular implementation for the generic |
| 1230 | function called @var{name}. The implementation code is given by | 1230 | function called @var{name}. The implementation code is given by |
| 1231 | @var{body}. If present, @var{docstring} is the documentation string | 1231 | @var{body}. If present, @var{docstring} is the documentation string |
| @@ -1252,15 +1252,20 @@ defined with @code{cl-defstruct} (@pxref{Structures,,, cl, Common Lisp | |||
| 1252 | Extensions for GNU Emacs Lisp}), or of one of its parent classes. | 1252 | Extensions for GNU Emacs Lisp}), or of one of its parent classes. |
| 1253 | @end table | 1253 | @end table |
| 1254 | 1254 | ||
| 1255 | Alternatively, the argument specializer can be of the form | 1255 | Method definitions can make use of a new argument-list keyword, |
| 1256 | @code{&context (@var{expr} @var{spec})}, in which case the value of | 1256 | @code{&context}, which introduces extra specializers that test the |
| 1257 | @var{expr} must be compatible with the specializer provided by | 1257 | environment at the time the method is run. This keyword should appear |
| 1258 | @var{spec}; @var{spec} can be any of the forms described above. In | 1258 | after the list of required arguments, but before any @code{&rest} or |
| 1259 | other words, this form of specializer uses the value of @var{expr} | 1259 | @code{&optional} keywords. The @code{&context} specializers look much |
| 1260 | instead of arguments for the decision whether the method is | 1260 | like regular argument specializers---(@var{expr} @var{spec})---except |
| 1261 | applicable. For example, @code{&context (overwrite-mode (eql t))} | 1261 | that @var{expr} is an expression to be evaluated in the current |
| 1262 | will make the method compatible only when @code{overwrite-mode} is | 1262 | context, and the @var{spec} is a value to compare against. For |
| 1263 | turned on. | 1263 | example, @code{&context (overwrite-mode (eql t))} will make the method |
| 1264 | applicable only when @code{overwrite-mode} is turned on. The | ||
| 1265 | @code{&context} keyword can be followed by any number of context | ||
| 1266 | specializers. Because the context specializers are not part of the | ||
| 1267 | generic function's argument signature, they may be omitted in methods | ||
| 1268 | that don't require them. | ||
| 1264 | 1269 | ||
| 1265 | The type specializer, @code{(@var{arg} @var{type})}, can specify one | 1270 | The type specializer, @code{(@var{arg} @var{type})}, can specify one |
| 1266 | of the @dfn{system types} in the following list. When a parent type | 1271 | of the @dfn{system types} in the following list. When a parent type |