>
>  Gr, top-posting...

Sorry, was on mobile. ;-)

However, since the existence of the word "yield" is the only thing that
> marks a coroutine now, how about using a variant of that for the final
> value, e.g. "yield final $foo"?


What's the final value? The last "yield"ed value or a return?

Just to give you some real world example:
If you're using "return", it would look like that:

public function getSession ($sessionId) {
    $result = yield $this->redis->get("session.{$sessionId}")); // We're
waiting here until redis responded.
    return json_decode($result);
}

Currently, it looks like this:

public function getSession ($sessionId) {
    $result = yield $this->redis->get("session.{$sessionId}"));
    yield json_decode($result);
}

Or maybe even that:

public function getSession ($sessionId) {
    $result = yield $this->redis->get("session.{$sessionId}"));
    yield "return" => json_decode($result);
}

I think having the possibility for a return here, would make that code a
lot easier to read and understand.

Regards, Niklas

Reply via email to