called @var{name}; @pxref{Blocks and Exits}.
@end defmac
+@defmac cl-iter-defun name arglist body@dots{}
+This form is identical to the regular @code{iter-defun} form, except
+that @var{arglist} is allowed to be a full Common Lisp argument
+list. Also, the function body is enclosed in an implicit block
+called @var{name}; @pxref{Blocks and Exits}.
+@end defmac
+
@defmac cl-defsubst name arglist body@dots{}
This is just like @code{cl-defun}, except that the function that
is defined is automatically proclaimed @code{inline}, i.e.,
2015-03-03 Daniel Colascione <dancol@dancol.org>
+ * emacs-lisp/cl-macs.el (cl-iter-defun): Add cl-iter-defun.
+
* emacs-lisp/generator.el (iter-defun): Correctly propagate
docstrings and declarations to underlying function.
(form `(defun ,name ,@(cdr res))))
(if (car res) `(progn ,(car res) ,form) form)))
+;;;###autoload
+(defmacro cl-iter-defun (name args &rest body)
+ "Define NAME as a generator function.
+Like normal `iter-defun', except ARGLIST allows full Common Lisp conventions,
+and BODY is implicitly surrounded by (cl-block NAME ...).
+
+\(fn NAME ARGLIST [DOCSTRING] BODY...)"
+ (declare (debug
+ ;; Same as iter-defun but use cl-lambda-list.
+ (&define [&or name ("setf" :name setf name)]
+ cl-lambda-list
+ cl-declarations-or-string
+ [&optional ("interactive" interactive)]
+ def-body))
+ (doc-string 3)
+ (indent 2))
+ (require 'generator)
+ (let* ((res (cl--transform-lambda (cons args body) name))
+ (form `(iter-defun ,name ,@(cdr res))))
+ (if (car res) `(progn ,(car res) ,form) form)))
+
;; The lambda list for macros is different from that of normal lambdas.
;; Note that &environment is only allowed as first or last items in the
;; top level list.