Re: Simpler implementation with R7RS parameters?
Marc Nieper-WiÃkirchen 05 Jun 2020 07:36 UTC
Am Fr., 5. Juni 2020 um 09:07 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
> Ah, yes. But if you say "yield is an identifier bound to syntax." as in the current srfi text, it does sound something special.
What would you propose? Do you think that there is some better wording?
>> (define-coroutine-generator f
>> (yield (lambda () (yield 1))))
>>
>> (define-coroutine-generator g
>> (yield
>> (let ((x (f)))
>> (if (proc? x) (x) x)))))
>>
>> (g) ;=> 1
>>
>> This won't work with dynamic scoping of `yield'. (One can probably
>> think of a much simpler example.)
>
>
> This yields 1 in my implementation (with replacing proc? with procedure?).
> Is it supposed to work differently?
Indeed, the example cannot show the difference. It was a bad one. Can
you try the following one?
(define-coroutine-generator f
(yield (lambda () (yield 1))))
(define-coroutine-generator g
(yield
(+ 1 (let ((x (f)))
(if (proc? x) (x) x)))))
(g) ;=> 2