Function: iter-yield-from

iter-yield-from is a macro defined in generator.el.gz.

Signature

(iter-yield-from VALUE)

Documentation

When used inside a generator function, delegate to a sub-iterator.

The values that the sub-iterator yields are passed directly to the caller, and values supplied to iter-next are sent to the sub-iterator. iter-yield-from evaluates to the value that the sub-iterator function returns via iter-end-of-sequence.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/generator.el.gz
(defmacro iter-yield-from (value)
  "When used inside a generator function, delegate to a sub-iterator.
The values that the sub-iterator yields are passed directly to
the caller, and values supplied to `iter-next' are sent to the
sub-iterator.  `iter-yield-from' evaluates to the value that the
sub-iterator function returns via `iter-end-of-sequence'."
  (let ((errsym (cps--gensym "yield-from-result"))
        (valsym (cps--gensym "yield-from-value")))
    `(let ((,valsym ,value))
       (unwind-protect
            (condition-case ,errsym
                (let ((vs nil))
                  (while t
                    (setf vs (iter-yield (iter-next ,valsym vs)))))
              (iter-end-of-sequence (cdr ,errsym)))
         (iter-close ,valsym)))))