New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntactic sugar #10

Closed
uasan opened this Issue Jan 12, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@uasan

uasan commented Jan 12, 2018

Current syntax for Fiber creating:

$handle = function($a, $b){};  // declare handle
$fiber  = new Fiber($handle);  // instance Fiber
$fiber->resume(1, 2);          // first call handle
$fiber->resume(3);             // subsequent calls 

Replace to:

async function handle($a, $b){}; // declare handle Fiber
$fiber = handle(1, 2);           // instance new Fiber and first call handle
$fiber->resume(3);               // subsequent calls 

Current syntax yield:

$result = Fiber::yield($a + $b);

Replace to:

$result = await $a + $b;

I understand that the Fiber will be used at the level of PHP frameworks, in the userland interface will be an abstract framework API, but still this sugar is easier to write, remember and understand async code.

Thanks.

@lvht

This comment has been minimized.

Show comment
Hide comment
@lvht

lvht Jan 12, 2018

Member

TLTR: No.


Fiber is a standalone php module. And it is impossible to add keyword to the PHP language by a module.

Adding the keyword async and await will change the PHP language grammar but offer almost no benefit. It will be hard to persuade the community to accept such change.


As the Fiber is on its early stage, there are more work on it's implementation. I think we need to spent all effort on the php kernel land code.

Member

lvht commented Jan 12, 2018

TLTR: No.


Fiber is a standalone php module. And it is impossible to add keyword to the PHP language by a module.

Adding the keyword async and await will change the PHP language grammar but offer almost no benefit. It will be hard to persuade the community to accept such change.


As the Fiber is on its early stage, there are more work on it's implementation. I think we need to spent all effort on the php kernel land code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment