unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59140: 29.0.50; iter-yield from lambda
@ 2022-11-09  1:22 Michael Heerdegen
  2023-09-15 19:56 ` Max Brieiev
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2022-11-09  1:22 UTC (permalink / raw)
  To: 59140; +Cc: okamsn


Hello,

In emacs-help (Okamsn <okamsn@protonmail.com>) it has been pointed to
the issue that `iter-yield' (from generator.el) is not supported in some
contexts - contexts where yielding happens from inside a lambda
expression or directly (like here when mapping over a sequence), e.g.

     (setq iter-maker (iter-lambda (x)
                        (seq-doseq (item x)
                          (iter-yield item))))
     (setq my-iter (funcall iter-maker '(1 2 3)))
     (iter-next my-iter)

  ~~> (void-function cps-internal-yield)

(seq-doseq expands to more or less just mapc+lambda) or

     (setq iter-maker (iter-lambda (x)
                        (seq-do #'iter-yield x)))
     (setq my-iter (funcall iter-maker '(1 2 3)))
     (iter-next my-iter)
  ~~> (error "‘iter-yield’ used outside a generator")

These examples are written correctly but seem to hit an undocumented
limitation of the implementation in generator.el

I quote Stefan Monnier answering what should be done:

> IIRC, one of the main limitations of `generator.el` is that it doesn't
> handle `lambda` (and neither should you use `#'iter-yield`, IIRC).
> 
> I don't really know how to go about fixing it.
> 
> A good first step would be to make sure it emits an error (or a warning)
> when you use `#'iter-yield` or when you call `#'iter-yield` from with
> a lambda expression.

TIA,

Michael.







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

end of thread, other threads:[~2023-09-17  6:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-09  1:22 bug#59140: 29.0.50; iter-yield from lambda Michael Heerdegen
2023-09-15 19:56 ` Max Brieiev
2023-09-15 22:18   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16 19:39     ` Max Brieiev
2023-09-16 21:31       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16  1:56   ` Michael Heerdegen
2023-09-17  6:32     ` Max Brieiev

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).