aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2016-01-24 03:35:39 +0300
committerDmitry Gutov2016-01-24 03:35:39 +0300
commit62f4ed477ebcbe56087bb1df96340530c84b33a9 (patch)
treefbd7e9c0d34d978ce62e45bdaae1806a1dde2d65
parent2111e0eeb5a10389790e39b9103fa73bcf2b75c0 (diff)
downloademacs-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.el24
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)
198BODY, if present, is used as the body of a default method. 196DEFAULT-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.
362I.e. it defines the implementation of NAME to use for invocations where the 360I.e. it defines the implementation of NAME to use for invocations where the
363value of the dispatch argument matches the specified TYPE. 361values of the dispatch arguments match the specified TYPEs.
364The dispatch argument has to be one of the mandatory arguments, and 362The dispatch arguments have to be among the mandatory arguments, and
365all methods of NAME have to use the same argument for dispatch. 363all methods of NAME have to use the same set of arguments for dispatch.
366The dispatch argument and TYPE are specified in ARGS where the corresponding 364Each dispatch argument and TYPE are specified in ARGS where the corresponding
367formal argument appears as (VAR TYPE) rather than just VAR. 365formal argument appears as (VAR TYPE) rather than just VAR.
368 366
369The optional second argument QUALIFIER is a specifier that 367The 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
374The absence of QUALIFIER means this is a \"primary\" method. 372The absence of QUALIFIER means this is a \"primary\" method.
375 373
376Other than a type, TYPE can also be of the form `(eql VAL)' in 374TYPE can be one of the basic types (see the full list and their
377which case this method will be invoked when the argument is `eql' to VAL. 375hierarchy in `cl--generic-typeof-types'), CL struct type, or an
376EIEIO class.
377
378Other than that, TYPE can also be of the form `(eql VAL)' in
379which case this method will be invoked when the argument is `eql'
380to VAL, or `(head VAL)', in which case the argument is required
381to 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)