Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128933 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 9D3711A00BC for ; Thu, 23 Oct 2025 16:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761235312; bh=0skHXeM/OTspUqXU8Fajn1ymKHYDR0AleBmZhg2LnS4=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=XJu/padAhtJavTGqi6Llv2vXYA02GC6ZXrWbiQzhHu2iNZ0F70Ft5WSSsaqJoUHad 3rG/3fSZ7V0/g1Vf42N3iJ2t4zYc/vqdr9/KDNIbUWikT+an6nguFb9TJCsrV0K6Je psiXFwZECXapNJEK9hoE3y6Q972BDp4MIz0ZMjGSoZtOKoJk0zrB/YrYNxpkQxCqfQ kDolVzcgs91cIF8QvL4kcgowMRk8WkzMy0lGtJKPDgLUpoZcUOHOaPCzw40/usnUhu BBD2yDfXbtcODIxV+9Btz7cUD/wWoIEX4+r22Xe31L8rI+70Y2pNCujabdvmHLpRqb 0CDt20VrF4VBQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2E0AB180078 for ; Thu, 23 Oct 2025 16:01: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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from nebula.zort.net (nebula.zort.net [96.241.205.3]) (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, 23 Oct 2025 16:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zort.net; s=zort; t=1761235305; bh=0skHXeM/OTspUqXU8Fajn1ymKHYDR0AleBmZhg2LnS4=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=om8fZVrLcJCCpAWknhqSRj185FEpft/dpA/texYI+WOGeKX79mRBYdSdMSzeZeQfM t5ivQbkjGDu1Dc2BFmu8cVg0sasEAbtoJ2KywiB1qhim2OjFR1do8Gx+dVp9X/QSsM CQq+TId4NNmcHV6mkm9/AkEbt6spIoStKz2I9Fx8= Received: from smtpclient.apple (pulsar.zort.net [96.241.205.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nebula.zort.net (Postfix) with ESMTPSA id 38A2A1300503; Thu, 23 Oct 2025 12:01:45 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 In-Reply-To: Date: Thu, 23 Oct 2025 12:01:35 -0400 Cc: Rob Landers , Aleksander Machniak , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: 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> To: Edmond Dantes X-Mailer: Apple Mail (2.3826.700.81) From: jbafford@zort.net (John Bafford) Hi, > On Oct 23, 2025, at 01:56, Edmond Dantes wrote: >=20 > Hi, >=20 >> it makes that future RFC's job unnecessary harder >=20 > If you want to make PHP multithreaded and plan to change the language > syntax while avoiding future issues, it would be reasonable to discuss > the changes using specific syntax examples. > Can you show me the cases you want to implement? I don't have any specific use-cases in mind. I'm just trying to be = forward-looking here. But what is clear is that some people would like = to see async/await in PHP. This RFC would ostensibly be a step towards = that. All I'm trying to do is make sure that it doesn't put up = roadblocks for future enhancements. >> I can't find where this `awaitXX` function is defined > It was in the third version of the RFC. >=20 >> So you say "Awaitable objects do not return multiple values. >=20 > 1. multiple values: >=20 > ```php > $fs =3D new FileSystemEvents(); >=20 > // At that moment, the user created file1 and then file2. > $event =3D await($fs); >=20 > // Now: $event contains [file1, file2] -- The coroutine captured two > events at once. > ``` >=20 > 2. signe value: >=20 > ```php > $fs =3D new FileSystemEvents(); >=20 > // At that moment, the user created file1 and then file2. > $event =3D await($fs); >=20 > // Now: $event contains file1 -- ONLY ONE VALUE! > ``` >=20 >> but to me it feels like you're just dismissing Rob and my concern > It=E2=80=99s hard three times over, because the expression = foreach(await() as > ) is considered valid only if await returns a value once. I think there are two bad designs here. First: If you have something that streams results, then the interface to = access should reflect streaming. And it should be an error (preferably = thrown at compile time) if you try and treat a stream as a single value, = or a single value as a stream. This is whether it's async or not. And we = already have an interface one can implement if one has an iterable = sequence of events, so that you can either call the iteration functions = directly, or use foreach() which provides syntactic sugar over that. Second: it should be emitting either a stream of files, or a stream of = arrays of files. Returning list|File is not a great pattern. >> btw, if you haven't read through the Swift Evolution proposals for = structured concurrency, > Thanks for the idea. I haven=E2=80=99t read that discussion. > Is it https://forums.swift.org/t/se-0304-structured-concurrency/45314 = ? That's the first review thread for Swift's Structured Concurrency = proposal. The proposal itself is here, along with links to the three = pitch and three review threads, and the async/await and actor proposals: = https://github.com/swiftlang/swift-evolution/blob/main/proposals/0304-stru= ctured-concurrency.md (see also the async/await and actors proposals, linked from that = proposal. Note that a nontrivial portion of the proposal covers actor = isolation, which is obviously beyond the scope of this RFC, but whether = or not a future multithreading async extension uses actor isolation as = its safety concept, those concepts are still generally relevant.) >> What I'm proposing that specifically Async\protect() and *forcibly* = cancelling coroutines should be removed. > This RFC does not include forced coroutine termination, only > cooperative cancellation using exceptions. > If we remove the protect function, we=E2=80=99ll also have to remove > cooperative cancellation. Why is the protect function needed, then? If you request cancellation, = the coroutine is free to ignore the cancellation and run to completion. = That's what makes it cooperative. >> The RFC should include a description of _why_ cooperative = cancellation has been chosen. > If I add detailed explanations for every _why_ in the RFC, it might > never get read :) In addition to Rob's comments on expressing intent and a source for = documentation: concurrency is a large, confusing, and _hard_ topic. = Anything that's unclear or underspecified is only going to cause = problems in the long run. It's better to be as clear as possible so that = when it eventually comes to voting, you have less chance of people = voting No because of that reason. > Thanks, Ed -John=