Re: [RFC Discuss] Generator Delegation
| From: | Bob Weinand | Date: | Mon, 02 Mar 2015 10:11:02 +0000 |
| Subject: | Re: [RFC Discuss] Generator Delegation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84160@lists.php.net to get a copy of this message | ||
> Am 02.03.2015 um 01:17 schrieb Niklas Keller <me@kelunik.com>:
>
> 2015-03-02 0:52 GMT+01:00 Daniel Lowrey <rdlowrey@php.net>:
>
>> Hi folks,
>>
>> I'd like to initiate discussion on a proposal to implement generator
>> delegation via the following new syntax inside generator functions:
>>
>> yield * <expr>
>>
>> The Generator Delegation RFC is available here:
>>
>> https://wiki.php.net/rfc/generator-delegation
>>
>> This proposal is conceptually related to (and requires functionality
>> proposed by) the forerunning Generator Return Expressions RFC here:
>>
>> https://wiki.php.net/rfc/generator-return-expressions
>>
>>
>> Thanks for your time,
>>
>> Daniel
>>
>
> The proposed syntax has an issue:
>
> <?php
>
> function a () {
> echo yield * 3;
> }
>
> $a = a();
> $a->send(42);
>
> http://3v4l.org/n1sGb#v550
>
> This is currently valid PHP.
>
> Regards, Niklas
Hey,
I think we could use "yield from" as operator here.
Yes, BC. So, I won't make "from" a keyword, but rather specify an own token for
"yield from" (T_YIELD_FROM).
That way we have no BC break, except someone tries to yield a constant named "from". I
think that's a really minor break … and in case this breaks someones code, he needs to wrap
the constant in parenthesis: "yield (from)".
We can have nice syntax here with a minimal break, so, then, why not?
Thanks,
Bob