Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128925 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 539C21A00BC for ; Thu, 23 Oct 2025 08:18:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761207536; bh=qsbXQ7lJFL1RN1ud9JPbbgg+nfy94nbTZ/kyKJjAV6g=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=A17YKlvqcuXyeL12wvQe0oy9DvhDhgOL/e1KIYJC0yUeaJkyYPKZ7gAN5sfL52L0V 3s1w/yIenHQ1os2LakkVgkupHhcgTFPTFDDSXmMMvDLUDDy1Y4W52kQvuFXHnI8qil 3MMBYnBjrHs5CsvjdDcZPR8gnFDiwSRzg/0ynHXtVeC53N6u3Pd8qC7x0stvofGyRE oZ0lS7CVK3JnWRpdmvDgdZIyYs65iVOCghCSvIv0UszNvmIL3emMByjLaFsSKIPhZf e3FGTu9jwk7aonMVronnfuLocJins443QZ4hw1klksdpNYH7EudQndIPx8YAP9ja/p 858zhdz0nknlw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2E5C9180340 for ; Thu, 23 Oct 2025 08:18:51 +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=-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 23 Oct 2025 08:18:50 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 64804EC019D; Thu, 23 Oct 2025 04:18:45 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-05.internal (MEProxy); Thu, 23 Oct 2025 04:18:45 -0400 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=fm3; t=1761207525; x= 1761293925; bh=qsbXQ7lJFL1RN1ud9JPbbgg+nfy94nbTZ/kyKJjAV6g=; b=c o04GG428vejZXnwkxCew6yaWbIsqB9mWVfEPglVsaRH9i5WSTP2RXLVhZq11cW8c gw9gIqzDFZrTl4EkysmUFY0IQwv6+Gi+PZBAZtYeHqe8uIa0srXhdMXDT61Zs2So 6DDlZ2UrGZx207suhVevb8qTCzpZQmdJo3jhEGO9gVitFQqEpCwMpXk8Qu3U60SV A28y+Cu7TBef4c+SOrAxG6QIPq7WwQUjzdFs0SdxMgihhAx12Wlr8ihIWofhvUwK 5am8EjvDYWPzAAPoZeiBMycj3I4zGQCL6ZO2ctdD1AwpxUhqCblu7NJJkO31WY7r sOFgK6v1dAgPo7fNWgxVg== 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=fm2; t= 1761207525; x=1761293925; bh=qsbXQ7lJFL1RN1ud9JPbbgg+nfy94nbTZ/k yKJjAV6g=; b=o1V828FMDPn1p9bKLbLsfoust2ga7UGZd0ub40oj2KwNqFh7IZE 7K4FFDATActZcDkPwsuF47VeGIO/dmYYacZqLTIiUOG2t5NutmgkT3dUpnvS45N5 RVYGgDQiJJCF/BiZMwGOep4zWukX6eTleY5FCAjoHSGa3BL/S7Lgvix0TRa6ZtKV DrcSJl1qHyJBj5x5JuIBwl1IHdXRYyO+CGeR5ZHOVMfBO1cbdvgrB5CNY/vbpScv IeLIsq7BUWP79gyz4SA5eEHtaTwAkVM8q3dLJko1kbgg93IOUX6Ivfi3YDNFXjL2 nfo4GadchJJeSDH+AQoF9iMdmusyZsAcelA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddugeehleeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfn rghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtth gvrhhnpeeiueethedvvdefjefhgfeiheelheehtdfhfeekjefflefgvedvkeduteejjedt tdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehroh gssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphhtthhopeefpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopegvughmohhnugdrhhhtsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthho pegrrghrohhnsehtrhhofihskhhirdgtohhm X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id DED86182007A; Thu, 23 Oct 2025 04:18:44 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AQpA1KTaY2GJ Date: Thu, 23 Oct 2025 10:18:23 +0200 To: "Edmond Dantes" Cc: "Aaron Piotrowski" , "PHP Internals" Message-ID: <51a4f8e0-2dbe-444c-aeda-162020c022c5@app.fastmail.com> In-Reply-To: References: <0e4e39d6-9cc9-4970-92e0-2463143b4011@app.fastmail.com> <37180d8d-85b4-49a3-a672-334bf4329470@app.fastmail.com> <2f8524a7-dea2-4fbf-933a-c538d3706253@app.fastmail.com> <151800a7-1094-49bc-8e43-c593a74741af@app.fastmail.com> Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 Content-Type: multipart/alternative; boundary=57ef65230f18472ea97d4012c2ba1960 From: rob@bottled.codes ("Rob Landers") --57ef65230f18472ea97d4012c2ba1960 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, Oct 23, 2025, at 09:59, Edmond Dantes wrote: > I=E2=80=99d like you to have the full information necessary to make an > informed decision. >=20 > There are two or more channel objects that need to be awaited. How > should this be implemented? >=20 > Currently > ```php > [$result1, $result2] =3D awaitAny($channel1, $channel2); > ``` >=20 > With Futures: > ```php > // Like Rust > [$result1, $result2] =3D awaitAny($channel1->recv(), $channel2->recv()= ); > ``` >=20 > What I dislike about the Future example is that it creates an object > that isn=E2=80=99t actually needed. > What I like about it is that it clearly shows what action is being awa= ited. Specifically: > What I dislike about the Future example is that it creates an object > that isn=E2=80=99t actually needed. Why does it need to 'create' an object? Flyweights are a well known patt= ern and PHP knows the number of references to any specific object. Preve= nt them from being GC'd and have a pool of them for reuse. You don't nee= d to actually create anything. That being said, that's an optimization f= or later. As for which one I'd rather have, I'd rather have the one where my examp= les hold true: assert(awaitAll($a, $b, $c) =3D=3D=3D [await($a), await($b), await($c)]); It's clear what it does and that it is just a shorthand. When that fails= , we have issues. =E2=80=94 Rob --57ef65230f18472ea97d4012c2ba1960 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Thu, Oct 23, 2025, at 09:59, Edmond Dantes wrote:
I=E2=80=99d like= you to have the full information necessary to make an
informe= d decision.

There are two or more channel objec= ts that need to be awaited. How
should this be implemented?

Currently
```php
[$result1, $= result2] =3D awaitAny($channel1, $channel2);
```
With Futures:
```php
// Like Rust
<= div>[$result1, $result2] =3D awaitAny($channel1->recv(), $channel2-&g= t;recv());
```

What I dislike abo= ut the Future example is that it creates an object
that isn=E2= =80=99t actually needed.
What I like about it is that it clear= ly shows what action is being awaited.

=
Specifically:

What I dislike about the Future example is that it cr= eates an object
that isn=E2=80=99t actually needed.

Why does it need to 'create' an object? Flyw= eights are a well known pattern and PHP knows the number of references t= o any specific object. Prevent them from being GC'd and have a pool of t= hem for reuse. You don't need to actually create anything. That being sa= id, that's an optimization for later.

As for wh= ich one I'd rather have, I'd rather have the one where my examples hold = true:

assert(awaitAll($a, $b, $c) =3D=3D=3D [aw= ait($a), await($b), await($c)]);

It's clear wha= t it does and that it is just a shorthand. When that fails, we have issu= es.

=E2=80=94 Rob
--57ef65230f18472ea97d4012c2ba1960--