Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128855 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 DBEB81A00BC for ; Thu, 16 Oct 2025 14:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1760625788; bh=pxCJ+eoJiBp+djX0OQayCwEBV9kszIhpmQ5vvsARZas=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=hbVn5evwr2EKbriqjgEepp0g9chldLhCZUyXaO3dlZ+RyTrQuKpxyAyTQ/NrX0Jie JZ1rFG1MdumT9lG4plnpsUg8bm9xlv1ps5muVeIJ4+oV2lK07BnE9I0tDl02wKZxTn LbEywC4VpmL6NuW3zGT58BGnVmh5oF3T/YLi5zn5hNoNTX6DOhhuw43NPgtcJzVl/X /T9jpo6MR/xRx/RRqsBE1+4n34TAqPYVAqaIKObDLyNJyTy05tarzhu7bDd33//jMR r5EzkPHFGsa7lxrqd/s0YdXcbyozh8Zqylpm8yQhBAs5Dv9BodfAFVmh9FLcrHqPG0 kZIKO3AmFY5+g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 65362180078 for ; Thu, 16 Oct 2025 14:43:07 +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.1 required=5.0 tests=BAYES_50,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.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-a8-smtp.messagingengine.com (fhigh-a8-smtp.messagingengine.com [103.168.172.159]) (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 ; Thu, 16 Oct 2025 14:43:06 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id B288D1400109; Thu, 16 Oct 2025 10:43:00 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-05.internal (MEProxy); Thu, 16 Oct 2025 10:43:00 -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=1760625780; x= 1760712180; bh=pxCJ+eoJiBp+djX0OQayCwEBV9kszIhpmQ5vvsARZas=; b=U /QouaPkDOo+jalocGzz2ay2JXqfQUTWt3nVZt04rX+e8GPVYAoRYacGmMKAac6Og wtlrQ3232P6Ky7oz2C6zpL6O1yF2IyFayedFDYgADcIaQwmpE/n8jwF+JOp8kONn xuiri+2Y16fk8MrBYmwWdrAFRadtCysgDjsBjmxtE4wves3zkjL3pWDTpkvoHFa7 aEhgeMRv/hyjVQHiNlWzfbsAcccb/1q/YxKWA1DDTkiGdwQqxXKBx/4+Hz+K5rSy m5IjVGDch/LpCAbkZX+InWz7Cug18aKj1u5/k9GjYPZu5IdjJ2MccDfNEo9givr4 Fk37L5kREh/F66UO0iKAg== 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= 1760625780; x=1760712180; bh=pxCJ+eoJiBp+djX0OQayCwEBV9kszIhpmQ5 vvsARZas=; b=u/21a1OXF2bLvIyYsXxrcqnkDBsXwUnbhVU4a/WsD4ytrF77gHz xbyZ1nSnjihCS6eDs84mVclGNhl3b2zxhjS2QS98sstAyW0yuqHYp/TskBiXK4aS PsrCNipSy7nYjgBS+IXlmLUIfqGqewoHPWrzjS3aZ1pD3AR+J1qezcLnrWpHLdjv oLhFR5M2MdX8ZdWAVLbdbujAxbfq66+nYuMwvI5SBMc7mTfy/L2+77ND/BWAPcqI hWzMg8dOHjNSbuJ1eDmh4bVR+BhlrNcRcvhbqDseEEcXCYK99icyuWzw6HejjJ+a OazUEU+4tc7MXmoUY4qn7YusG62c8y0fK9Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduvdeiheeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefoggffhffvvefkjghfufgtsegrtderre ertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgv ugdrtghouggvsheqnecuggftrfgrthhtvghrnhepieeuteehvddvfeejhffgieehleehhe dthfefkeejffelgfevvdekudetjeejtddtnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspg hrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvggumhhonhgu rdhhthesghhmrghilhdrtghomhdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsth hsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 44E361820054; Thu, 16 Oct 2025 10:43:00 -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: AG5VjklPAjNR Date: Thu, 16 Oct 2025 16:42:39 +0200 To: "Edmond Dantes" Cc: internals@lists.php.net Message-ID: In-Reply-To: References: <2b9fd3ec-50ca-41e4-985a-274f886df8b3@app.fastmail.com> <2e39e211-c816-41db-a079-f2c6b3934e0a@app.fastmail.com> <436d4ede-c08e-4e7d-9ae2-8342f7f827ed@app.fastmail.com> Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 Content-Type: multipart/alternative; boundary=03740351e4a24d9e97c9363613943817 From: rob@bottled.codes ("Rob Landers") --03740351e4a24d9e97c9363613943817 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, Oct 16, 2025, at 15:19, Edmond Dantes wrote: > > Would it be better to instead of having ->awaitCompletion (which fee= ls like an implicit implementation of Awaitable without an explicit impl= mentation -- which is the part that was bothering me), maybe having some= thing like ->joinAll() or ->joinOnCancellation()? > > That way someone like me won't come along and wrap them in an Awaita= ble because it looks Awaitable. >=20 > For example, you have an interface `DataBaseAdmin` with a `removeDB()` > method and a class that implements it. > You need to be able to delete the database, but with an additional > condition. So you create a decorator class with a method > `ContextualDBAdmin::removeDBWhen($extraRules)`. >=20 > As a result, the decorator class is logically associated with the > `DataBaseAdmin` interface. >=20 > The question is: **so what?** I think we might be talking past each other a little. You said earlier that one of the goals here is to prevent misuse (e.g. u= nbounded or foreign awaits). I completely agree and that=E2=80=99s exact= ly why I=E2=80=99m suggesting a rename. From the outside, a method calle= d awaitCompletion() looks and behaves like an Awaitable, even though the= type explicitly isn=E2=80=99t one. That contradiction encourages people= to wrap it to =E2=80=9Cmake it awaitable,=E2=80=9D which re-introduces = the very problem you=E2=80=99re trying to avoid. Renaming it to something like joinAll() or joinAfterCancellation() keeps= the semantics intact while communicating the intent: this isn=E2=80=99t= a future; it=E2=80=99s a container join. That small change would make t= he interface self-documenting and harder to misuse. >=20 > > It also might be a good idea to make specifying a timeout in ms mand= atory, instead of a taking an Awaitable/Cancellation. >=20 > The idea is correct, but there will definitely be someone who says > they need more flexibility. > And it's true you can create a `DeferredCancellation` and forget to > finish it. :) >=20 > There are a lot of such subtle points, and they can be discussed endle= ssly. > But I wouldn=E2=80=99t spend time on them. That's what we are here to do, no? Discussion is useful if it makes thin= gs better than the sum of their parts. > > It also might be good to provide a realistic looking example showing= a "bad case" of how this is dangerous instead of simply saying that it = is, showing how a scope is not a 'future', > > but a container, and preemptively mention TaskGroups, linking to the= future scope (which it should also probably be listed there as well). >=20 > 1. It=E2=80=99s very difficult to write a realistic example that=E2=80= =99s still small. I'll give it a go: $scope =3D new Scope(); // Library code spawns in my scope (transitively) $scope->spawn(fn() =3D> thirdPartyOperation()); // may spawn more // Looks innocent, but this can wait on foreign work: $scope->awaitCompletion(Async\timeout(60000)); // rename -> joinAll(...)? > 2. The `TaskGroup` or `CoroutineGroup` class is left for future > discussion. In the final documentation, it will be exactly as you > suggested. My point is that it wasn't listed in "future scope" of the RFC, though t= hey're mentioned throughout the document, in passing. =E2=80=94 Rob --03740351e4a24d9e97c9363613943817 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Thu, Oct 16, 2025, at 15:19, Edmond Dantes wrote:
> Would it be= better to instead of having ->awaitCompletion (which feels like an i= mplicit implementation of Awaitable without an explicit implmentation --= which is the part that was bothering me), maybe having something like -= >joinAll() or ->joinOnCancellation()?
> That way some= one like me won't come along and wrap them in an Awaitable because it lo= oks Awaitable.

For example, you have an interfa= ce `DataBaseAdmin` with a `removeDB()`
method and a class that= implements it.
You need to be able to delete the database, bu= t with an additional
condition. So you create a decorator clas= s with a method
`ContextualDBAdmin::removeDBWhen($extraRules)`= .

As a result, the decorator class is logically= associated with the
`DataBaseAdmin` interface.

=
The question is: **so what?**

I think we might be talking past each other a little.
<= br>
You said earlier that one of the goals here is to prevent = misuse (e.g. unbounded or foreign awaits). I completely agree and that=E2= =80=99s exactly why I=E2=80=99m suggesting a rename. From the outside, a= method called awaitCompletion() looks and behaves like an Awaitable, ev= en though the type explicitly isn=E2=80=99t one. That contradiction enco= urages people to wrap it to =E2=80=9Cmake it awaitable,=E2=80=9D which r= e-introduces the very problem you=E2=80=99re trying to avoid.
=
Renaming it to something like joinAll() or joinAfterCance= llation() keeps the semantics intact while communicating the intent: thi= s isn=E2=80=99t a future; it=E2=80=99s a container join. That small chan= ge would make the interface self-documenting and harder to misuse.
=


<= /div>
> It also might be a good idea to make specifying a timeout= in ms mandatory, instead of a taking an Awaitable/Cancellation.

The idea is correct, but there will definitely be some= one who says
they need more flexibility.
And it's tr= ue you can create a `DeferredCancellation` and forget to
finis= h it. :)

There are a lot of such subtle points,= and they can be discussed endlessly.
But I wouldn=E2=80=99t s= pend time on them.

That's what we = are here to do, no? Discussion is useful if it makes things better than = the sum of their parts.

> It also might be good to provide a realisti= c looking example showing a "bad case" of how this is dangerous instead = of simply saying that it is, showing how a scope is not a 'future',
> but a container, and preemptively mention TaskGroups, linking= to the future scope (which it should also probably be listed there as w= ell).

1. It=E2=80=99s very difficult to write a= realistic example that=E2=80=99s still small.
I'll give it a go:

$sco= pe =3D new Scope();

// Library code spawns in my scope (transitively)
<= div>$scope->spawn(fn() =3D> thirdPartyOperation()); // = may spawn more

// Looks innocent, but this can wait on foreign work:
$scope->awaitCompletion(Async\timeout(60000)); // renam= e -> joinAll(...)?

2. The `TaskGroup` or `CoroutineGroup` = class is left for future
discussion. In the final documentatio= n, it will be exactly as you
suggested.

My point is that it wasn't listed in "future scope" of t= he RFC, though they're mentioned throughout the document, in passing.

=E2=80=94 Rob
--03740351e4a24d9e97c9363613943817--