diff options
| author | Dmitry Gutov | 2016-01-24 03:35:39 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2016-01-24 03:35:39 +0300 |
| commit | 62f4ed477ebcbe56087bb1df96340530c84b33a9 (patch) | |
| tree | fbd7e9c0d34d978ce62e45bdaae1806a1dde2d65 | |
| parent | 2111e0eeb5a10389790e39b9103fa73bcf2b75c0 (diff) | |
| download | emacs-62f4ed477ebcbe56087bb1df96340530c84b33a9.tar.gz emacs-62f4ed477ebcbe56087bb1df96340530c84b33a9.zip | |
Update cl-defgeneric and cl-defmethod docstrings
* lisp/emacs-lisp/cl-generic.el: Remove outdated TODO item.
(cl-defgeneric): Rename BODY to DEFAULT-BODY.
(cl-defmethod): Mention that multiple dispatch arguments are
allowed. Document supported types. (Bug#22336)
| -rw-r--r-- | lisp/emacs-lisp/cl-generic.el | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index b0815f5cf5f..5413bdbdf7f 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el | |||
| @@ -83,8 +83,6 @@ | |||
| 83 | ;; - A generic "filter" generalizer (e.g. could be used to cleanly add methods | 83 | ;; - A generic "filter" generalizer (e.g. could be used to cleanly add methods |
| 84 | ;; to cl-generic-combine-methods with a specializer that says it applies only | 84 | ;; to cl-generic-combine-methods with a specializer that says it applies only |
| 85 | ;; when some particular qualifier is used). | 85 | ;; when some particular qualifier is used). |
| 86 | ;; - A way to dispatch on the context (e.g. the major-mode, some global | ||
| 87 | ;; variable, you name it). | ||
| 88 | 86 | ||
| 89 | ;;; Code: | 87 | ;;; Code: |
| 90 | 88 | ||
| @@ -195,9 +193,9 @@ OPTIONS-AND-METHODS currently understands: | |||
| 195 | - (declare DECLARATIONS) | 193 | - (declare DECLARATIONS) |
| 196 | - (:argument-precedence-order &rest ARGS) | 194 | - (:argument-precedence-order &rest ARGS) |
| 197 | - (:method [QUALIFIERS...] ARGS &rest BODY) | 195 | - (:method [QUALIFIERS...] ARGS &rest BODY) |
| 198 | BODY, if present, is used as the body of a default method. | 196 | DEFAULT-BODY, if present, is used as the body of a default method. |
| 199 | 197 | ||
| 200 | \(fn NAME ARGS [DOC-STRING] [OPTIONS-AND-METHODS...] &rest BODY)" | 198 | \(fn NAME ARGS [DOC-STRING] [OPTIONS-AND-METHODS...] &rest DEFAULT-BODY)" |
| 201 | (declare (indent 2) (doc-string 3)) | 199 | (declare (indent 2) (doc-string 3)) |
| 202 | (let* ((doc (if (stringp (car-safe options-and-methods)) | 200 | (let* ((doc (if (stringp (car-safe options-and-methods)) |
| 203 | (pop options-and-methods))) | 201 | (pop options-and-methods))) |
| @@ -360,10 +358,10 @@ the specializer used will be the one returned by BODY." | |||
| 360 | (defmacro cl-defmethod (name args &rest body) | 358 | (defmacro cl-defmethod (name args &rest body) |
| 361 | "Define a new method for generic function NAME. | 359 | "Define a new method for generic function NAME. |
| 362 | I.e. it defines the implementation of NAME to use for invocations where the | 360 | I.e. it defines the implementation of NAME to use for invocations where the |
| 363 | value of the dispatch argument matches the specified TYPE. | 361 | values of the dispatch arguments match the specified TYPEs. |
| 364 | The dispatch argument has to be one of the mandatory arguments, and | 362 | The dispatch arguments have to be among the mandatory arguments, and |
| 365 | all methods of NAME have to use the same argument for dispatch. | 363 | all methods of NAME have to use the same set of arguments for dispatch. |
| 366 | The dispatch argument and TYPE are specified in ARGS where the corresponding | 364 | Each dispatch argument and TYPE are specified in ARGS where the corresponding |
| 367 | formal argument appears as (VAR TYPE) rather than just VAR. | 365 | formal argument appears as (VAR TYPE) rather than just VAR. |
| 368 | 366 | ||
| 369 | The optional second argument QUALIFIER is a specifier that | 367 | The optional second argument QUALIFIER is a specifier that |
| @@ -373,8 +371,14 @@ modifies how the method is combined with other methods, including: | |||
| 373 | :around - Method will be called around everything else | 371 | :around - Method will be called around everything else |
| 374 | The absence of QUALIFIER means this is a \"primary\" method. | 372 | The absence of QUALIFIER means this is a \"primary\" method. |
| 375 | 373 | ||
| 376 | Other than a type, TYPE can also be of the form `(eql VAL)' in | 374 | TYPE can be one of the basic types (see the full list and their |
| 377 | which case this method will be invoked when the argument is `eql' to VAL. | 375 | hierarchy in `cl--generic-typeof-types'), CL struct type, or an |
| 376 | EIEIO class. | ||
| 377 | |||
| 378 | Other than that, TYPE can also be of the form `(eql VAL)' in | ||
| 379 | which case this method will be invoked when the argument is `eql' | ||
| 380 | to VAL, or `(head VAL)', in which case the argument is required | ||
| 381 | to be a cons with VAL as its head. | ||
| 378 | 382 | ||
| 379 | \(fn NAME [QUALIFIER] ARGS &rest [DOCSTRING] BODY)" | 383 | \(fn NAME [QUALIFIER] ARGS &rest [DOCSTRING] BODY)" |
| 380 | (declare (doc-string 3) (indent 2) | 384 | (declare (doc-string 3) (indent 2) |