Re: [RFC Discuss] Generator Delegation
| From: | Rowan Collins | Date: | Tue, 03 Mar 2015 13:27:16 +0000 |
| Subject: | Re: [RFC Discuss] Generator Delegation | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84235@lists.php.net to get a copy of this message | ||
Niklas Keller wrote on 03/03/2015 12:52:
2015-03-03 13:27 GMT+01:00 Rowan Collins <rowan.collins@gmail.com <mailto:rowan.collins@gmail.com>>:You mean instead of ->getReturn()? Something like ->getFinalValue() or ->getFinalResult() Regards, -- Rowan Collins [IMSoP]Bob Weinand wrote on 03/03/2015 12:08:Why should the word "return" be unique to methods or functions?It just doesn't feel like the same thing as a return value to me, for the same reason a generator doesn't feel like the same thing as a function. In "function foo() { return 42; }", "return" means "this is what you'll get when you run foo()"; in "function foo() { return 42; yield; }", what you get when you run foo() is a pointer to the resumable state, and return means "this is what you'll get if you ask the generator/coroutine instance you get by running foo() for its final result".It's still different from "return". You said, it "mark[s] the final result", so I'd expect that finally yielded value would be at the iterator, but it's not. It's separate. How would you call the method then, that makes that "yield final" value available?