Re: [VOTE] True Async RFC 1.6

From: Date: Sat, 22 Nov 2025 12:12:53 +0000
Subject: Re: [VOTE] True Async RFC 1.6
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to internals+get-129390@lists.php.net to get a copy of this message
> Edmond Dantes <edmond.ht@gmail.com> hat am 22.11.2025 13:01 CET geschrieben: > > > Hello > > > function return types should not depend on the outside context (spawn, hook, ini, etc.) > > because when the code gets more complex, it's very hard to find the outside context. > > What does “outside context” mean? > > I just want to understand the practical use of functions with Promise. > The code above makes sense only if there is awaitAll. > > $promise1 = file_get_content_async("file1.txt"); > $promise2 = file_get_content_async("file2.txt"); > $promise3 = file_get_content_async("file3.txt"); > > awaitAll($promise1, ....); > > But you can achieve exactly the same effect without special functions. > The only difference is that the _async function inside might be > optimized in some way. > Or is there something else? > > --- > Ed Hello, basically in $result = foo(spawn(bar(baz(file_get_contents())))); file_get_contents() receives outside context from spawn() to turn into async mode. Also foo(), bar(), baz() can be in different namespaces, different classes, so by looking at the code calling file_get_contents(), it's not clear if the result is sync or async. Another example: $foo = file_get_contents('foo.txt'); $result = foo($foo); should be equal to: $result = foo(file_get_contents('foo.txt')); but having: $foo = file_get_contents('foo.txt'); // sync $result = spawn($foo); // error because $foo is string would not be eqaul to: $result = spawn(file_get_contents('foo.txt')); // async Best Regards Thomas

« previous php.internals (#129390) next »