GNU bug report logs - #59140
29.0.50; iter-yield from lambda

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Wed, 9 Nov 2022 01:24:01 UTC

Severity: wishlist

Found in version 29.0.50

Full log


Message #28 received at 59140 <at> debbugs.gnu.org (full text, mbox):

From: Max Brieiev <max.brieiev <at> gmail.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 59140 <at> debbugs.gnu.org, okamsn <at> protonmail.com, monnier <at> iro.umontreal.ca
Subject: Re: bug#59140: 29.0.50; iter-yield from lambda
Date: Sun, 17 Sep 2023 09:32:31 +0300
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Max Brieiev <max.brieiev <at> gmail.com> writes:
>
>> For example, this:
>>
>>     (iter-defun my-generator ()
>>       (funcall (lambda () (iter-yield 5))))
>>
>> would be expanded by iter-defun macro into this:
>>
>>     (...
>>       (let ((gen (iter-lambda () (iter-yield 5))))
>>         (iter-next (funcall gen))))
>>
>> Does it make sense?
>
> Does it?  Isn't the `let' expression equivalent to just `5'?  With other
> words: you don't yield from an outside generator, as far as I
> understand (or am I wrong? what's the content of your "..."?).
>
> Michael.

You are right, the code is wrong, it should probably return a generator
instead. What I attempted to show is how lambda would be turned into
`iter-lambda`, conceptually. "..." is some expansion performed by
`iter-defun`. In my intuition, if `iter-yield` is encountered inside a
lambda, then it would be converted into generator, and then advance the
created generator to the first yield expression, such that the following
`iter-next` would resume execution from the suspnension point. But I
might be wrong, the topic of generators is new to me, and I need to
study it.




This bug report was last modified 1 year and 271 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.