Are there any future plans for - async/await?
This need to know now, not to use these words to constants, and class names...
Are there any future plans for - async/await?
This need to know now, not to use these words to constants, and class names...
async/await is the single greatest addition to modern application
development in the last 20 years. Every language needs these features.
Microsoft completely solved the core problems surrounding
multithreaded programming with the concepts behind these two keywords.
+1 to reserving these keywords even though PHP isn't currently a
multithreaded language. IMO, PHP CLI is just as viable as PHP SAPI.
And PHP CLI is where multithreaded functionality makes a lot more sense.
--
Thomas Hruska
CubicleSoft President
I've got great, time saving software that you will find useful.
Are there any future plans for - async/await?
This need to know now, not to use these words to constants, and class
names...async/await is the single greatest addition to modern application
development in the last 20 years. Every language needs these features.
Microsoft completely solved the core problems surrounding multithreaded
programming with the concepts behind these two keywords.
While not disputing this claim I think PHP should only reserve words
when there are somewhat concrete plans for their use. There have been
talks and draft RFCs for things like void returns and union types with
Foo | null, so reserving void
and null
makes sense. Perhaps there
is a massive effort somewhere off-list but I am not aware of any plans
on implementing async/await in PHP.
If you are worried about them becoming reserved then simply do not use
async
and await
as method, constant or class names. There ends the
issue (in my opinion).
Den 2015-09-28 kl. 18:53, skrev Levi Morrison:
Are there any future plans for - async/await?
This need to know now, not to use these words to constants, and class
names...async/await is the single greatest addition to modern application
development in the last 20 years. Every language needs these features.
Microsoft completely solved the core problems surrounding multithreaded
programming with the concepts behind these two keywords.
While not disputing this claim I think PHP should only reserve words
when there are somewhat concrete plans for their use. There have been
talks and draft RFCs for things like void returns and union types with
Foo | null, so reservingvoid
andnull
makes sense. Perhaps there
is a massive effort somewhere off-list but I am not aware of any plans
on implementing async/await in PHP.
In the interview with Dmitry asynchronous behaviour was
mentioned as one key area for the future, see:
https://blog.amasty.com/php-7-and-script-languages-future-insights-from-lead-zend-com-developer
Hope it materialises some day!
Regards //Björn
On Mon, Sep 28, 2015 at 9:17 AM, Thomas Hruska thruska@cubiclesoft.com
wrote:Are there any future plans for - async/await?
This need to know now, not to use these words to constants, and class
names...async/await is the single greatest addition to modern application
development in the last 20 years. Every language needs these features.
Microsoft completely solved the core problems surrounding multithreaded
programming with the concepts behind these two keywords.While not disputing this claim I think PHP should only reserve words
when there are somewhat concrete plans for their use. There have been
talks and draft RFCs for things like void returns and union types with
Foo | null, so reservingvoid
andnull
makes sense. Perhaps there
is a massive effort somewhere off-list but I am not aware of any plans
on implementing async/await in PHP.If you are worried about them becoming reserved then simply do not use
async
andawait
as method, constant or class names. There ends the
issue (in my opinion).
This model totally failed for us in the past. And given that these keywords
will be used for anything related to async APIs, let reserve them and put
our users on the safe side already.
Hi
2015-09-29 7:30 GMT+02:00 Pierre Joye pierre.php@gmail.com:
This model totally failed for us in the past. And given that these keywords
will be used for anything related to async APIs, let reserve them and put
our users on the safe side already.
While I understand the concern, I don't think we should just go
reserve a bunch of keywords if there is no concrete plan an
implementation model, maybe an RFC is having more no votes than yes
votes etc, and we are stuck with 2 keywords that won't be used for
another few years at least
--
regards,
Kalle Sommer Nielsen
kalle@php.net
Hi
2015-09-29 7:30 GMT+02:00 Pierre Joye pierre.php@gmail.com:
This model totally failed for us in the past. And given that these keywords
will be used for anything related to async APIs, let reserve them and put
our users on the safe side already.While I understand the concern, I don't think we should just go
reserve a bunch of keywords if there is no concrete plan an
implementation model, maybe an RFC is having more no votes than yes
votes etc, and we are stuck with 2 keywords that won't be used for
another few years at least
I wouldn't block them in the parser. We however could list them in the
naming guide http://php.net/manual/en/userlandnaming.php but for keeping
this relevant we have to maintain that page :)
Async/multi-threading functionality can also be built without keywords
using a "future" or "promise" model like C++ or JavaScript.
johannes
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming, at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...
As mentioned you don't need any special syntax or reserved words for
asynchronous execution, these problems are not solved by adding two words
to the parser. The API's might not be very nice, and there aren't enough of
them, but there is absolutely nothing stopping you writing asynchronous
code, and there wasn't in PHP4 either ...
Cheers
Joe
On Tue, Sep 29, 2015 at 1:20 PM, Johannes Schlüter johannes@schlueters.de
wrote:
Hi
2015-09-29 7:30 GMT+02:00 Pierre Joye pierre.php@gmail.com:
This model totally failed for us in the past. And given that these
keywords
will be used for anything related to async APIs, let reserve them and
put
our users on the safe side already.While I understand the concern, I don't think we should just go
reserve a bunch of keywords if there is no concrete plan an
implementation model, maybe an RFC is having more no votes than yes
votes etc, and we are stuck with 2 keywords that won't be used for
another few years at leastI wouldn't block them in the parser. We however could list them in the
naming guide http://php.net/manual/en/userlandnaming.php but for keeping
this relevant we have to maintain that page :)Async/multi-threading functionality can also be built without keywords
using a "future" or "promise" model like C++ or JavaScript.johannes
Sorry, that was all over the place ... was on way out the door ...
What I should have said is that async/await don't directly solve problems,
they are nice calling conventions for async APIs, but the APIs must exist
before we talk about reserving or adding anything else.
The real problem is that there is a lack of nice async API's, this problem
can be solved independently of any syntax, and should be.
Of course, there isn't much of a drive to create such API's internally ...
they might never come ... thankfully projects like icicle, and others, have
us pretty well covered. The fact is that there isn't much to gain by
duplicating that functionality internally, it won't really go remarkably
faster, and there would be far less people able to contribute to their
development.
That's better ...
Cheers
Joe
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming, at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...As mentioned you don't need any special syntax or reserved words for
asynchronous execution, these problems are not solved by adding two words
to the parser. The API's might not be very nice, and there aren't enough of
them, but there is absolutely nothing stopping you writing asynchronous
code, and there wasn't in PHP4 either ...Cheers
JoeOn Tue, Sep 29, 2015 at 1:20 PM, Johannes Schlüter <johannes@schlueters.de
wrote:
Hi
2015-09-29 7:30 GMT+02:00 Pierre Joye pierre.php@gmail.com:
This model totally failed for us in the past. And given that these
keywords
will be used for anything related to async APIs, let reserve them and
put
our users on the safe side already.While I understand the concern, I don't think we should just go
reserve a bunch of keywords if there is no concrete plan an
implementation model, maybe an RFC is having more no votes than yes
votes etc, and we are stuck with 2 keywords that won't be used for
another few years at leastI wouldn't block them in the parser. We however could list them in the
naming guide http://php.net/manual/en/userlandnaming.php but for keeping
this relevant we have to maintain that page :)Async/multi-threading functionality can also be built without keywords
using a "future" or "promise" model like C++ or JavaScript.johannes
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming, at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...
Actually, it does. Asynchronous and multithreaded programming are
attempts at solving the exact same problem: Simultaneously handling
multiple data streams in whatever form that takes whether that be
network, hard drive, random device XYZ, RAM, or even CPU. The former
says, "Let's wait until we can read or write and continue when we have
data." The latter says, "Let's read and write but let the OS handle
context switching to give the appearance of simultaneously handling
multiple data streams."
Async/await is both the best of and THE solution to both worlds. It
allows, on a single thread, multiple functions to be executed
simultaneously, resuming each function exactly where it left off when
the async call "returns" to the await. This feature results in elegant
userland code that never unexpectedly blocks, transparently fires up
threads wherever necessary, maintains mapped pools of handles behind the
scenes, and resumes functions where they left off on the original
thread. There is no other equivalent model today that doesn't involve
tons of error-prone plumbing. Also, with today's error-prone models,
portions of async/await actually can't be implemented without resorting
to questionable assembler hacks (hello 1980's!). As I said earlier,
async/await is the single greatest solution to multithreading (because
very little code actually needs multiple threads in an async/await
world) but it also dramatically simplifies asynchronous programming.
Async/await also can't be implemented in libraries - it has to be
implemented in the core of the language itself and therein lies both the
genius for userland code (thank you Microsoft!) as well as the
horribleness for language designers (thank you Microsoft?). Everyone
who writes "userland code" in any given language wants this, but no one
ever wants to be responsible for correctly implementing this feature
because there is much evil hackery required to pull it off.
For the most part, PHP follows a single-threaded, synchronous/sometimes
asynchronous model, which works well for web, and therefore means users
can somewhat fake async/await with promises/futures and no one there
will really notice because no one there will really use either feature.
However, the single-threaded model doesn't necessarily apply to CLI
where some of the real power of PHP can be leveraged - with long-running
processes, unlimited CPU, and fewer RAM limitations, a lot of
possibilities open up.
So the underlying question really is: Is PHP, particularly CLI, ever
going to leave its single-threaded model? If not, then this discussion
dies here. But if so, then async/await is the most desirable solution,
albeit being extremely evil and difficult to implement.
https://channel9.msdn.com/Events/Build/2012/3-011
--
Thomas Hruska
CubicleSoft President
I've got great, time saving software that you will find useful.
Thomas,
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming, at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...Actually, it does. Asynchronous and multithreaded programming are attempts
at solving the exact same problem: Simultaneously handling multiple data
streams in whatever form that takes whether that be network, hard drive,
random device XYZ, RAM, or even CPU.
Parallelism and concurrency are not the same thing. There are a ton of
resources on this, but I'll point to two specifically, Rob Pike (from
GoLang): https://www.youtube.com/watch?v=cN_DpYBzKso and Joe's own
blog: http://blog.krakjoe.ninja/2015/07/the-universe-is-not-aware.html
Async/await is both the best of and THE solution to both worlds.
A whole lot of people would argue that. It's not that it's not a good
solution, but it's A solution. Each mechanism (event loops,
threading, channels, compiler-driven-concurrency, etc) has its own
pros and cons, and handle different situations better.
A simple example is that raw threads can scale across CPUs, but event
loops typically can't (since it's typically single threaded). That's
not to say it's impossible to write a cross-CPU event loop, but that
requires additional implementation/constraints.
There are such non-trivial tradeoffs to each, that there's no clear
"best" solution to any of it. Async/await is one way. Golang's
channels are another subtly different yet very good way as well.
Another even better way may be to take an approach which is to leave
it to the compiler to figure out what can be made async (though that
may not be strictly possible with PHP in most cases).
Claiming that one technique is the victor, without explicitly stating
the constraints that are required, is not a great idea.
Anthony
Hi Thomas,
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming, at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...Actually, it does. Asynchronous and multithreaded programming are attempts at solving the exact same problem: Simultaneously handling multiple data streams in whatever form that takes whether that be network, hard drive, random device XYZ, RAM, or even CPU. The former says, "Let's wait until we can read or write and continue when we have data." The latter says, "Let's read and write but let the OS handle context switching to give the appearance of simultaneously handling multiple data streams."
Async/await is both the best of and THE solution to both worlds. It allows, on a single thread, multiple functions to be executed simultaneously, resuming each function exactly where it left off when the async call "returns" to the await. This feature results in elegant userland code that never unexpectedly blocks, transparently fires up threads wherever necessary, maintains mapped pools of handles behind the scenes, and resumes functions where they left off on the original thread. There is no other equivalent model today that doesn't involve tons of error-prone plumbing. Also, with today's error-prone models, portions of async/await actually can't be implemented without resorting to questionable assembler hacks (hello 1980's!). As I said earlier, async/await is the single greatest solution to multithreading (because very little code actually needs multiple threads in an async/await world) but it also dramatically simplifies asynchronous programming. Async/await also can't be implemented in libraries - it has to be implemented in the core of the language itself and therein lies both the genius for userland code (thank you Microsoft!) as well as the horribleness for language designers (thank you Microsoft?). Everyone who writes "userland code" in any given language wants this, but no one ever wants to be responsible for correctly implementing this feature because there is much evil hackery required to pull it off.
For the most part, PHP follows a single-threaded, synchronous/sometimes asynchronous model, which works well for web, and therefore means users can somewhat fake async/await with promises/futures and no one there will really notice because no one there will really use either feature. However, the single-threaded model doesn't necessarily apply to CLI where some of the real power of PHP can be leveraged - with long-running processes, unlimited CPU, and fewer RAM limitations, a lot of possibilities open up.
So the underlying question really is: Is PHP, particularly CLI, ever going to leave its single-threaded model? If not, then this discussion dies here. But if so, then async/await is the most desirable solution, albeit being extremely evil and difficult to implement.
https://channel9.msdn.com/Events/Build/2012/3-011
--
Thomas Hruska
CubicleSoft PresidentI've got great, time saving software that you will find useful.
--
Asynchronous programs do not solve the same problem as multithreading. Asynchronous programs cannot execute code in parallel like a multithreaded program. Asynchronous code relies on non-blocking I/O to continuously execute available tasks in a single thread of execution, but only one function is ever being executed at a time within that thread. Often separate threads are used to implement non-blocking I/O or other tasks. Asynchronous coding is a complement to multithreading, not a replacement.
Implementing elegant, readable, and stable asynchronous code in userland PHP code is very possible. In fact, I’ve done exactly this with Icicle (https://github.com/icicleio/icicle). Icicle uses generators and promises to implement coroutines. When a coroutine yields a promise, the coroutine is interrupted until the promise resolves, sending or throwing the resolution value into the generator. While a coroutine is interrupted, other code in the program is given the chance to be executed. This behavior is similar to async/await, instead using a generator as the async function and yield as await. There are several packages available for Icicle that implement non-blocking I/O and concurrency (multithreading). There are no extensions required for Icicle and no black magic – just making good use of the tools already available.
Regards,
Aaron Piotrowski
Implementing elegant, readable, and stable asynchronous code in userland PHP code is very possible. In fact, I’ve done exactly this with Icicle (https://github.com/icicleio/icicle). Icicle uses generators and promises to implement coroutines. When a coroutine yields a promise, the coroutine is interrupted until the promise resolves, sending or throwing the resolution value into the generator. While a coroutine is interrupted, other code in the program is given the chance to be executed. This behavior is similar to async/await, instead using a generator as the async function and yield as await. There are several packages available for Icicle that implement non-blocking I/O and concurrency (multithreading). There are no extensions required for Icicle and no black magic – just making good use of the tools already available.
My experience says that callback, promise, yield, not transparent as
the async/await in С#.
In other languages:
Python - coroutines with async and await
https://www.python.org/dev/peps/pep-0492/
ECMAScript
https://github.com/lukehoban/ecmascript-asyncawait
When Node.js appear async/await, many developers and projects will
migrate to a Node.js, if PHP is not implement async APIs.
Hopefully, Dmitry Stogov and others, will make another surprise:
PHP-Next-Async? :)
When Node.js appear async/await, many developers and projects will
migrate to a Node.js, if PHP is not implement async APIs.Hopefully, Dmitry Stogov and others, will make another surprise:
PHP-Next-Async? :)
My claim is that if you're doing something CPU-intensive which can be
parallelized in PHP you're most likely doing something wrong but you
should send this to a processing service. PHP imo needs a stronger
async-IO story.
Node.js is a completely different thing and people don't switch because
it has a async feature, but people pick it (aside from hype) since it
solves different issues.
Anyways. This is irrelevant for this thread. This thread was about
reserving async/await keywords. The discussion has proven that there is
no clear plan. Therefore we should not reserve any keywords.
If anybody has good research and a proposal they can start a new
discussion but let's finish this thread. If you disagree with my
assumptions feel free to answer privately but don't spam everybody
with off-topic comments :-)
Thanks,
johannes
On Wed, Sep 30, 2015 at 12:08 AM, Johannes Schlüter
johannes@schlueters.de wrote:
When Node.js appear async/await, many developers and projects will
migrate to a Node.js, if PHP is not implement async APIs.Hopefully, Dmitry Stogov and others, will make another surprise:
PHP-Next-Async? :)My claim is that if you're doing something CPU-intensive which can be
parallelized in PHP you're most likely doing something wrong but you
should send this to a processing service. PHP imo needs a stronger
async-IO story.Node.js is a completely different thing and people don't switch because
it has a async feature, but people pick it (aside from hype) since it
solves different issues.Anyways. This is irrelevant for this thread. This thread was about
reserving async/await keywords. The discussion has proven that there is
no clear plan. Therefore we should not reserve any keywords.
Yep I also agree with that, we should reserve when we are sure (voted RFC)
keywords will be used.
Julien.P
Implementing elegant, readable, and stable asynchronous code in userland PHP code is very possible. In fact, I’ve done exactly this with Icicle (https://github.com/icicleio/icicle). Icicle uses generators and promises to implement coroutines. When a coroutine yields a promise, the coroutine is interrupted until the promise resolves, sending or throwing the resolution value into the generator. While a coroutine is interrupted, other code in the program is given the chance to be executed. This behavior is similar to async/await, instead using a generator as the async function and yield as await. There are several packages available for Icicle that implement non-blocking I/O and concurrency (multithreading). There are no extensions required for Icicle and no black magic – just making good use of the tools already available.
My experience says that callback, promise, yield, not transparent as
the async/await in С#.
In other languages:Python - coroutines with async and await
https://www.python.org/dev/peps/pep-0492/ECMAScript
https://github.com/lukehoban/ecmascript-asyncawait
Agreed, though in both languages, async / await started out by using
generators (yield) and futures (promises & callbacks). In JavaScript's
case, the implementation is actually still built on top of generators.
So, I'm confident we'll get there eventually.
When Node.js appear async/await, many developers and projects will
migrate to a Node.js, if PHP is not implement async APIs.Hopefully, Dmitry Stogov and others, will make another surprise:
PHP-Next-Async? :)
OT: I don't have any numbers, but I'm not so sure as many people
"switched" to Node.js as people claim. Node.js has a similar, but
distinct, goal that is different from PHP's.
--
Stephen
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming,
at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...Actually, it does. Asynchronous and multithreaded programming are
attempts at solving the exact same problem: Simultaneously handling
multiple data streams in whatever form that takes whether that be
network, hard drive, random device XYZ, RAM, or even CPU. The former
says, "Let's wait until we can read or write and continue when we have
data." The latter says, "Let's read and write but let the OS handle
context switching to give the appearance of simultaneously handling
multiple data streams."
That description may have held a few years ago, when processes and threads were nearly always time-slices on a single CPU core, but surely on a modern system there can be real simultaneity, because even the cheapest laptop has multiple CPU cores. An asynchronous approach is useful for cases of "do something else while I wait for this background task to complete", but seems less so for "do both of these things actively, using whatever resource is available".
It may be that the first class of problem is more common, but that doesn't make the two equivalent.
Regards,
Rowan Collins
[IMSoP]
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming,
at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...Actually, it does. Asynchronous and multithreaded programming are
attempts at solving the exact same problem: Simultaneously handling
multiple data streams in whatever form that takes whether that be
network, hard drive, random device XYZ, RAM, or even CPU. The former
says, "Let's wait until we can read or write and continue when we have
data." The latter says, "Let's read and write but let the OS handle
context switching to give the appearance of simultaneously handling
multiple data streams."That description may have held a few years ago, when processes and threads were nearly always time-slices on a single CPU core, but surely on a modern system there can be real simultaneity, because even the cheapest laptop has multiple CPU cores. An asynchronous approach is useful for cases of "do something else while I wait for this background task to complete", but seems less so for "do both of these things actively, using whatever resource is available".
It may be that the first class of problem is more common, but that doesn't make the two equivalent.
Remember that discussion we had some years ago ? ;-)
Async IOs etc... some parts can still be found on the wiki
(https://wiki.php.net/ideas/php6/engine).
I hope we'll be able to collaborate about this subject for a PHP-Next,
like PHP 8.
Julien.P
We shouldn't reserve words on a whim ...
async/await doesn't solve any problems for multithreaded programming, at
all ... it solves problems for asynchronous programming, a different
concept ... let's not confuse the two ...
Agreed, the concepts are quite different, thought they can be related in
a way. More on that in a minute...
Actually, it does. Asynchronous and multithreaded programming are
attempts at solving the exact same problem: Simultaneously handling
multiple data streams in whatever form that takes whether that be
network, hard drive, random device XYZ, RAM, or even CPU. The former
says, "Let's wait until we can read or write and continue when we have
data." The latter says, "Let's read and write but let the OS handle
context switching to give the appearance of simultaneously handling
multiple data streams."
Actually, they don't attempt to solve the same problem (though some
problems can be solved with either). Concurrent programming (threads,
forks, or anything else that uses multiple execution contexts --
multiple program counters) has the purpose of enabling you to do two or
more things at once (as much as possible on the current CPU).
If you need to do two big ass math calculations, you can use
multithreading to do both at once. (I'll ignore instruction pipelining
restrictions and the context switching overhead curve for simplicity.)
In this example, asynchronous programming does nothing for us.
If you need to handle 10000 socket connections, threading isn't
practical with a thread-per-connection model. Here, async becomes useful
because the bottleneck is I/O, not CPU operations. Async programming
allows you to do other things instead of blocking the thread when doing
an I/O operation (... or a few other operation types).
So then, in summary, threads & multiprocessing enables you to do more
work simultaneously, while async maximizes the usefulness of each
thread you have. So using both is actually an incredibly good thing,
but they aren't the same nor accomplish the same thing. I hope what I
said made sense.
Now, on to async / await. :)
Async/await is both the best of and THE solution to both worlds. It
...
Yes. But not for the reason that I think you're thinking. Combining
concurrency with asynchronicity is the best of both worlds, and using
threads themselves in a non-blocking way with async / await (which are
strictly an async thing) is pretty powerful. Here's an example (in .NET):
static async void SlowAsync()
{
// Create a task which will be run in the threadpool
Task task = new Task(SlowAssOperation);
// Asynchronously wait (using the .NET event loop) for the thread to
complete
await task;
}
static void SlowAssOperation()
{
// Do something synchronous
Thread.Sleep(5000);
}
The fact that we can await something being run in a thread isn't a
property of threads, but a property of the .NET async event loop which
can listen for thread events without blocking.
Hope that clears some things up. Sorry for being long winded. :)
--
Stephen
So then, in summary, threads & multiprocessing enables you to do more
work simultaneously, while async maximizes the usefulness of each
thread you have. So using both is actually an incredibly good thing,
but they aren't the same nor accomplish the same thing. I hope what I
said made sense.
Well, you've successfully convinced me that PHP needs both
multi-threading and async IO. I hope you're happy now...
--Larry Garfield
So then, in summary, threads & multiprocessing enables you to do more
work simultaneously, while async maximizes the usefulness of each
thread you have. So using both is actually an incredibly good thing,
but they aren't the same nor accomplish the same thing. I hope what I
said made sense.Well, you've successfully convinced me that PHP needs both
multi-threading and async IO. I hope you're happy now...--Larry Garfield
Quite happy. Sorry about that... :)
--
Stephen
This model totally failed for us in the past. And given that these keywords
will be used for anything related to async APIs, let reserve them and put
our users on the safe side already.
Like that time we reserved use
way before namespaces made it into
the language?
-Sara
I think, we don't need to reserve words, until we decide to implement this.
The context sensitive scanner introduced in 7.0 makes the problem less
serious.
$ sapi/cli/php -r 'class foo { static function use() {echo "ok\n";}}
foo::use();'
ok
Sara, related question...
Is the semantic of async/await in Hack and Dart is the same?
Thanks. Dmitry.
On Mon, Sep 28, 2015 at 10:30 PM, Pierre Joye pierre.php@gmail.com
wrote:This model totally failed for us in the past. And given that these
keywords
will be used for anything related to async APIs, let reserve them and put
our users on the safe side already.Like that time we reserved
use
way before namespaces made it into
the language?-Sara
I think, we don't need to reserve words, until we decide to implement this.
The context sensitive scanner introduced in 7.0 makes the problem less
serious.$ sapi/cli/php -r 'class foo { static function use() {echo "ok\n";}}
foo::use();'
ok
I actually do agree, I was just winding up Pierre over his "totally
failed" assertion with a counter-example. :)
Is the semantic of async/await in Hack and Dart is the same?
If I knew what Dart's semantics were, I could tell you. :)
I do know it's based on C#'s implementation (as are many other
async/await implementations from what I'm told).
-Sara
I think, we don't need to reserve words, until we decide to implement
this.
The context sensitive scanner introduced in 7.0 makes the problem less
serious.$ sapi/cli/php -r 'class foo { static function use() {echo "ok\n";}}
foo::use();'
okI actually do agree, I was just winding up Pierre over his "totally
failed" assertion with a counter-example. :)Is the semantic of async/await in Hack and Dart is the same?
If I knew what Dart's semantics were, I could tell you. :)
I do know it's based on C#'s implementation (as are many other
async/await implementations from what I'm told).
Could you please take a quick look, because I afraid, that identical syntax
in different languages implements quite different semantic (I would be glad
to be wrong).
https://www.dartlang.org/articles/event-loop/
https://www.dartlang.org/articles/await-async/
https://www.dartlang.org/articles/beyond-async/
Thanks. Dmitry,
-Sara
This model totally failed for us in the past. And given that these keywords
will be used for anything related to async APIs, let reserve them and put
our users on the safe side already.Like that time we reserved
use
way before namespaces made it into
the language?
Just for history:
Actually we didn't reserve "use" on purpose. In commit 5463dd5b in
November 1999 Andi implemented a "use" feature which worked like
require_once, which was introduced later. The feature was removed but
unused "use" was kept by accident. In 5.3 we decided to use this unused
keyword instead of adding a new keyword.
https://github.com/php/php-src/commit/5463dd5b387298a84736e590e5d213f5bafe9435
We never purposely introduced a keyword. Only comparable thing was
backporting a the b"" prefix for binary strings from meanwhile abandoned
PHP 6 to 5.2(?).for forward compatibility. That has proven to be
useless.
Again an indication not to add async/wait keywords now as
placeholder. :-)
johannes
On Wed, Sep 30, 2015 at 1:22 AM, Johannes Schlüter johannes@schlueters.de
wrote:
On Mon, Sep 28, 2015 at 10:30 PM, Pierre Joye pierre.php@gmail.com
wrote:This model totally failed for us in the past. And given that these
keywords
will be used for anything related to async APIs, let reserve them and
put
our users on the safe side already.Like that time we reserved
use
way before namespaces made it into
the language?Just for history:
Actually we didn't reserve "use" on purpose. In commit 5463dd5b in
November 1999 Andi implemented a "use" feature which worked like
require_once, which was introduced later. The feature was removed but
unused "use" was kept by accident. In 5.3 we decided to use this unused
keyword instead of adding a new keyword.https://github.com/php/php-src/commit/5463dd5b387298a84736e590e5d213f5bafe9435
I think "use" was introduced by namespace implementation that was proposed
during 5.0 development and then reverted before GA release.
Thanks. Dmitry.
We never purposely introduced a keyword. Only comparable thing was
backporting a the b"" prefix for binary strings from meanwhile abandoned
PHP 6 to 5.2(?).for forward compatibility. That has proven to be
useless.Again an indication not to add async/wait keywords now as
placeholder. :-)johannes
Hello,
Are there any future plans for - async/await?
This need to know now, not to use these words to constants, and class names...--
As a few others have pointed out, the idea has certainly been discussed, but I’m not aware of any real progress toward integrating this into PHP in the near future. Implementing async/await in PHP is certainly possible, but will be no small task. I would love to see it in a 7.x release, but I’m thinking it might have to wait until 8 just because of all the changes that would be required.
I’ve created a library called Icicle (https://github.com/icicleio/icicle) that uses promises and generators to implement coroutines that use yield to interrupt execution of the coroutine until the promise is resolved. Combined with non-blocking I/O and concurrent execution implementations available in other packages designed for Icicle, you can create non-blocking and multi-threaded servers that are designed to be run from the CLI instead of the Apache SAPI, etc.
If you are not familiar with Icicle, I encourage you to take a quick look at the documentation, as the proceeding paragraph will make more sense if you understand how Icicle works.
I think the engine could use a similar strategy to that of Icicle for async/await. Async functions could return promises. Calling an async function with the await keyword would be similar to yielding a promise (or coroutine) within a coroutine in Icicle. If the await keyword is not used when calling an async function, this could be similar to calling Promise::wait() in Icicle, blocking control flow at that point until the promise is resolved. Perhaps in this way existing functions could be modified to support async/await while maintaining the existing blocking behavior when called without the await keyword.
Aaron Piotrowski