Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126637 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 qa.php.net (Postfix) with ESMTPS id 03DF01A00BC for ; Sat, 8 Mar 2025 08:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741422281; bh=iY8TzJgJnaTnOVXPOZokaKZmuV42Sr5uInEEKUxM2fw=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=Oz2zJQwKf+OQCDsBGcUh6aq1RsBDjXjf4n5bxeh0+X1IHzIpyV0TRmOLYLcpLSqIW tse5mCWwvIMewPjLAdc6VjR6JD7pRoEIPtUm7ZJAvbryv6iHILDJ+pzafxpxMoz1dD 8OwYiOcfLorJpXDV7PgvQdSokfJziGl787JxRalfGjz7ASpKpwzpH6Z7M1l7rLZ+1l qPDOGgnjdgPK0qxAPY/LOxtwB1afYt2p4qDRUJ12IrsgejLnn5i78PMdoJ8rYhhvmH n3swc7zqxKt+JTBHSN2b8zV4PX/h245dWwBJY85rFQj53s5xTHOm5ql98bZdLmOpPF 06r9N0y/cwpNg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6673018053E for ; Sat, 8 Mar 2025 08:24:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 8 Mar 2025 08:24:37 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id 9D114254011C; Sat, 8 Mar 2025 03:27:12 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-11.internal (MEProxy); Sat, 08 Mar 2025 03:27:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1741422432; x= 1741508832; bh=iY8TzJgJnaTnOVXPOZokaKZmuV42Sr5uInEEKUxM2fw=; b=A 69jILf6bN69UU2uMkHUKLPsBFQx9T2Zzt9vsGYGXegs57Ja6FOT3mNRIc5kxZAjC qZUoqMaTLb1c5ajmBeCjjYKOh71dLMzOOr7M4jhL22PhQ7c18AQEcIkPmQXTOibZ n+LG55rf0tphGngr0Y3zebfl2sbNX9HBmyFRbr4wQOw3oNJldE8eK3Ts1z/ej+v4 PYScnHN36eQEu8NCFn2bGIe2a+FjEBCwTWD5byEevaIsRwKDmOiYJFIeJhjjKLHI ivGbBuasFOD58AqlJnJTixab12dH0SHE6RjEmFpT7+0N9cSiP41mysfPvB8eHXHM PP+xS5zwHpKil0ylTFIyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1741422432; x=1741508832; bh=iY8TzJgJnaTnOVXPOZokaKZmuV42Sr5uInE EKUxM2fw=; b=huwm+fgHyBR4Hastegvj94T/9BJcplyiHE3d84aVVm14SZ9F8GB /HHoIyTzmSOiA4S9mO21pYjxe5PxHpNf3L2cAGGCoJ52g9A4hMNZDIwBzq11J20n /X1cD/oGzoCGkyicKPnUG02yLd7lwLCZb2wkHVC6eUJyXdAPuS5o8nkl5as6U4gm 4kYFPBDt2tx91AM9KbH4VtTPNE10Jhf935qf6M8HE7xL0e3ODa1Y3GPgH/rO/yFA I+HXt56DotBw91jscvcdLgLsUdCSvIkZWiAXI2WD+rLJJY+caZzqtdGweIjGtYpp 31QDw3Py5lWx1NZLwUiUkOrW4/GzcwrMAng== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduudeftdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvvefkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghr shdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhepie euteehvddvfeejhffgieehleehhedthfefkeejffelgfevvdekudetjeejtddtnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghoth htlhgvugdrtghouggvshdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtohepvggumhhonhgurdhhthesghhmrghilhdrtghomhdprhgtphhtthhope hinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 43953780068; Sat, 8 Mar 2025 03:27:12 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Sat, 08 Mar 2025 09:26:51 +0100 To: "Edmond Dantes" Cc: internals@lists.php.net Message-ID: <62505751-7d35-4ffd-ace2-cbf099ee2b8c@app.fastmail.com> In-Reply-To: References: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> <78a03dd0-fd4a-4f4a-ad8a-37e5704f06fc@app.fastmail.com> <08c8ad0b-e8f4-46e3-99f0-b80748d40b89@app.fastmail.com> <07973EAE-2D83-47A8-8FA0-84286C77C02B@rwec.co.uk> <48d66433-3ae9-4895-8361-7c81a0a3670d@app.fastmail.com> Subject: Re: [PHP-DEV] PHP True Async RFC Content-Type: multipart/alternative; boundary=7bf96d7fa1cf41bc9a51865a5b055a31 From: rob@bottled.codes ("Rob Landers") --7bf96d7fa1cf41bc9a51865a5b055a31 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Mar 8, 2025, at 09:24, Edmond Dantes wrote: > >=20 > >for($i =3D 0; $i < 10; $i++) $results[] =3D async\async(fn($f) =3D> f= ile_get_contents($f), > > $file[$i]); > > // convert $results into futures somehow -- though actually doesn't = look like it is > > possible. > > $results =3D async\awaitAll($results); > > >=20 > `Future` can be obtained via `getFuture()`, according to the current R= FC. > ```php > async\async(fn($f) =3D> file_get_contents($f), $file[$i])->getFuture(); > ``` =20 > And this semantics can be simplified to: =20 > ```async file_get_contents($file[$i]);``` > or > ```spawn file_get_contents($file[$i]);``` >=20 > From this perspective, I like that any function can be called with `sp= awn/async` without worrying about its internals or modifying its code. T= he pros and cons of this approach are well known. =20 Yes, that is much much nicer! It feel familiar to go: go file_get_contents($file[$i]) And yes, I realize that would be a fun error in go, but you get the gist. =E2=80=94 Rob --7bf96d7fa1cf41bc9a51865a5b055a31 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Sat, Mar 8, 2025, at 09:24, Edmond Dantes wrote:

>for($i =3D 0; $i < 10; $i++) $results[]= =3D async\async(fn($f) =3D> file_get_contents($f),
>= ; $file[$i]);
> // convert $results into futures someho= w -- though actually doesn't look like it is
> possible= .
> $results =3D async\awaitAll($results);
>

Future can be obtained = via getFuture(), according to the current RFC.
```php
async\async(fn($f) =3D> file_get_contents= ($f), $file[$i])->getFuture();
```  
And this semantics can be simplified to:  
```async file_get_contents($file[$i]);```
or
```spawn file_get_contents($file[$i]);```

From this perspective, I like that any function can be= called with spawn/async without worrying about its interna= ls or modifying its code. The pros and cons of this approach are well kn= own.  

Yes, th= at is much much nicer! It feel familiar to go:

<= div>go file_get_contents($file[$i])

And yes= , I realize that would be a fun error in go, but you get the gist.
=

=E2=80=94 Rob
--7bf96d7fa1cf41bc9a51865a5b055a31--