all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* generator documentation improvement
@ 2017-03-08 20:47 Paul Pogonyshev
  2017-03-08 21:06 ` Noam Postavsky
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Pogonyshev @ 2017-03-08 20:47 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

I suggest the following short improvement to documentation of
generator functions.  It took me very long to understand what's wrong
with my code.

Problem can be illustrated with this:

(require 'generator)
(defvar xxx 0)
(iter-defun my-iter ()
  (print "A")
  (let ((xxx nil))
    (print "B")
    (iter-yield 0)
    (print "C"))
  (print "D"))
(iter-do (x (my-iter))
  (print x))

If you evaluate the last form, you'll see "B" and "C" printed twice
because `let' for dynamic variable is internally implemented with
something similar to `unwind-protect'. However, when documentation
doesn't mention it, that's very hard to pinpoint.

Paul

[-- Attachment #2: generator-doc.diff --]
[-- Type: text/plain, Size: 506 bytes --]

diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 401a999cf2..e279be8557 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -730,7 +730,8 @@ result as its condition data.
 
 Any kind of Lisp code is valid inside @var{body}, but
 @code{iter-yield} and @code{iter-yield-from} cannot appear inside
-@code{unwind-protect} forms.
+@code{unwind-protect} forms or any dynamic @code{let} bindings,
+i.e. bindings for variables defined with @code{defvar}.
 
 @end defmac
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-11 21:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-08 20:47 generator documentation improvement Paul Pogonyshev
2017-03-08 21:06 ` Noam Postavsky
2017-03-08 21:28   ` Andreas Politz
2017-03-11 21:10     ` Paul Pogonyshev

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.