Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129392 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 9DF641A00BC for ; Sat, 22 Nov 2025 13:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763818514; bh=Y7B3FS/u3xtryOya+l04wpz7geSHQIR+sSPHyLa65Cs=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=neLPnN1fN1uPIt3olQMl1+je1wqTEghjD/W6Mj7/PvPGB1Yqtvk2XO/ChiL5xcN8H NPNrg3i+q/dE1+j+dzA5lzz3x5BhmHofVEfbUJZMZ0Onaoo05in2QmpzaJzQJ5DcGE DQtJYhJFVBmzBhlBwTYvLQZF+i2u6qoV2ODZtM24a9JmocVCmYadh07Msmn6AREY63 cKNRFu3z8FyeVtcaSE6htvob2b45Tk6tcaZHUoOfvKbyTuUzVVYPfRWiTUI+3TJpqT lOTQkUt2YyeEIC21mCt+74dyaxIktNj4iP7qOkBXW55YywsgO3bQwufLwN9PCKzW7v AQyp6A4tPDExQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 795D6180082 for ; Sat, 22 Nov 2025 13:35:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 22 Nov 2025 13:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thomasbley.de; s=s1-ionos; t=1763818506; x=1764423306; i=mails@thomasbley.de; bh=Y7B3FS/u3xtryOya+l04wpz7geSHQIR+sSPHyLa65Cs=; h=X-UI-Sender-Class:Date:From:To:Cc:Message-ID:In-Reply-To: References:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=1khUQt1ARmSRYIudUf4Kck9fmw/z1WL131O9WZAQ7ejhXyYgjmobXkRBW+ColKwz nVUKDuLtVIRSlsLOV3Qhcl8rfy3FJCQyQtge0sxznkk4VFEry17OQOxQ2rsoLrlWe QLBEa9iXQPct8njzpjBvSWQdPMz+6ZzW6AIg8zkZkPkAYo02DJGMguh84A8XO2Gwu s9fvGXmKR5nzkidq/zQPRWh+DCrV6Vc0MqGofuYKGyVrQ9ZjwMoAKrgjC6C5NbQ92 e2Xl0c++1xsIzrrqptadsPE0JC3b5zz1KhKh9gg3zPvkhyMwRKZEj7cEJ1Rub7ZEJ q4Log8l5feHAShjUpQ== X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from open-xchange-core-mw-default-1.open-xchange-core-mw-hazelcast-headless.open-xchange.svc.cluster.local ([10.73.157.130]) by mrelayeu.kundenserver.de (mreue011 [172.19.35.3]) with ESMTPSA (Nemesis) id 1N2lzA-1w7z2k2DFc-00s0gO; Sat, 22 Nov 2025 14:35:06 +0100 Date: Sat, 22 Nov 2025 14:35:06 +0100 (CET) To: Edmond Dantes Cc: internals@lists.php.net Message-ID: <92865666.4510.1763818506332@email.ionos.de> In-Reply-To: References: <383528143.397454.1763760932585@email.ionos.de> <691963327.399484.1763796022993@email.ionos.de> <1402906904.784903.1763811759896@email.ionos.de> <2015208655.784984.1763811978476@email.ionos.de> <980296152.1071.1763813573083@email.ionos.de> Subject: Re: [PHP-DEV] [VOTE] True Async RFC 1.6 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v8.38.93 X-Originating-Client: open-xchange-appsuite X-Provags-ID: V03:K1:QpzSfpXO9zDSlo27dLOucPI9ljylTFx5KohoT+ECd+4xRtrPfJf RfggvPS+KdgzIKsxPM40WuFZqMRn/F3JHru14fqrUeAxEXvROYXL608oay9tBf2XcI60M3s GOTqjTwakyNrzQwOdDRZnJtw+Qm5wJWwVuyFyHo/QNgl7yjs0jFlviTBU1W8Ga/ErW/mCrP b7o7sOXcUkIQmikkEtgng== UI-OutboundReport: notjunk:1;M01:P0:id6dN+ehvGE=;KXjGH6xJAuZRu9RlqRhRf1eUw05 gTqB8kD0V3SM/vgvygYd+b6NiiIG6drQeh3jn+6bBNbo+piO3lmzZ3Roa3XGOenktbi2fNvwl nKFYdq9ELwiMXJkY4D+1UShbPR4dhROwUoL+/Et4qngt7s/3UMRORkP3Bir4mbCA635wROLhm eLyymmpexlr5PAdJjTiBUQajTPhN/MnkwfnBtntjxsJF1au/+Am0ZlNeHx+fDjchv2/lzL6iR XoNrItXA3stxWnnjbXCeYZ9RWIQIf1cHzlJe8hvL135AgIPzFSr1/6SUwM19k3MsGxVNiQn+Y sur0Bwet/GbhpyNt7Alh9RV0zGijBnp0yw38DoDphldH3eCIJSg1HWWPFYT2MN1hM8UropQQm Job6KRnq0/81SwPqN7wWNU1Jio8Supg5ozXQXrDtOILE0A/+iPYXZyLZrdQSqbVBZArf4liel l0BJo2VtiDu7cFAQfTpTiFUav2QN0etSiLmaN4w13jMNBOcppUi1s0RaaBSNSlhkv+8kkV7rP eZGma+8Z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aQPBWs659wJ6cLts+ iYyEQ78VICWZRzoYVI0Y8fHALsHHj6viLv4mMXaZDHCV4IutJtDzqrQy9zo5j59LL3GQvLIj2 VmwCUM6DY/6LxV0pG0yY4SJGnyDihr9W4p0i+ImLA2POhxFnJmu9+9kMjfFduddaN5pFdswxO uFruNlmVHWRqd From: mails@thomasbley.de (Thomas Bley) > Edmond Dantes hat am 22.11.2025 13:37 CET geschrieb= en: >=20 > =20 > > basically in $result =3D foo(spawn(bar(baz(file_get_contents())))); fil= e_get_contents() receives outside context from spawn() to turn into async m= ode. > > Also foo(), bar(), baz() can be in different namespaces, different clas= ses, so by looking at the code calling file_get_contents(), it's not clear = if the result is sync or async. >=20 > Ok, then let=E2=80=99s look in detail at what is happening. >=20 > > foo(spawn(bar(baz(file_get_contents())))) >=20 > i.e. >=20 > ```php > $result =3D foo(spawn(bar(...), fn () =3D> baz(file_get_contents()))); > ``` >=20 > Did I understand the code correctly? > (Assume there was also some parameter there, like a file name.) >=20 > 1. We call `bar` in a separate coroutine, which > 2. First calls `file_get_contents` > 3. Then passes the result to the function `baz()` >=20 > Is that correct? >=20 > > Also foo(), bar(), baz() can be in different namespaces, different clas= ses, so by looking at the code calling file_get_contents(), it's not clear = if the result is sync or async. > If we are discussing the code above, then it returns a Promise not of > the file-reading result. > This is a completely different logic, and here the programmer clearly > intended to do something else. > What if the function baz replaces every a character with baz? It's ok. >=20 > ```php > $foo =3D file_get_contents('foo.txt'); // sync > $result =3D spawn($foo); // error because $foo is string > ``` >=20 > Here I don=E2=80=99t understand why someone would intentionally write inc= orrect code. >=20 > Code: > ```php > $result =3D foo(file_get_contents('foo.txt')); >=20 > // equivalent to > // the code below has no practical purpose >=20 > $result =3D foo(await(spawn(file_get_contents(...), 'foo.txt'))); > ``` >=20 > Is that correct? So I guess you want to use spawn() in a similar way as call_user_func() wor= ks. This changes the behavior of file_get_contents() from the outside, so it gi= ves file_get_contents() async context from the outside to behave differentl= y. Assuming every io operation inside spawn() runs async, I guess it's not pos= sible to mix sync and async io inside of one function. As mentioned before I'm not suggesting to use coroutines for async io. My r= ecommendation would be implementing new functions for async io and a promis= e object. Having everything that's executed async explicitly named "_async"= helps a lot when reading and understanding userland code. Regarding Coroutines in Go from userland perspective: the idea is nice but = often fails with deadlocks, hanging processes and having to run a "Data Rac= e Detector" all the time. Sure it's always the developers fault, but it hap= pens too often. Best Regards Thomas