Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128885 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 570661A00BC for ; Tue, 21 Oct 2025 16:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761065945; bh=ZkIxkphzqS1UrUC7ocOCARW8wb1g7UgQtXUUWiftGv0=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=gQkHVsLtEOPyPyEti8qzEvepbNzuaIofbXGyrAS7X5ibif6bgGMm1uEQ3ODOWl/bs 4NYsP5Fxil3pESmE4Q5vxox3vxbRFyVeMPURyG0Q95N3yUdAOCj++MowyHSJcARM5B XuzK9KYt2x8DBU1oiOw2TeC59PmgofvZwG40DXL/QJVBEcVoSP1P6OEX7JSQgwCI13 nv8jMmRYJoTUIiVCeRlP/jLIBEBo4buSAtwQS4cX9NdoUWV4da/JckfuAlB6qZUJTE vMRLIEVnjW1uYMolTSqD3XOHgEJ0oVTtdZTx2hXu+9XFiDQQN4DPIn9hLti4Hao6F7 Ptlo5APJWh1aQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2A21F1804C2 for ; Tue, 21 Oct 2025 16:59:05 +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=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (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 ; Tue, 21 Oct 2025 16:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761065938; bh=ZkIxkphzqS1UrUC7ocOCARW8wb1g7UgQtXUUWiftGv0=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=TeJnL+DimeHGsAN9RsJX7HPY35q8HThHtvSGGL5zvQK0N5EIh2x0YOF/Cb/wzI0pI tqGrYGOA8QsknSRnAjcJFzmPSN1B4WV5pMfiWsZhNW6NOV5NT7vle4jgM36Wh+pCEY rwFsbe1V3Hi/Wi6vZnUyEWHZw7TTEWXVQBg9M1vTtevV5Jw5Li6+Q6rVxFV3Q4tOaa Pl9ArEuMhdr7SO/s/8Adr9Incl/s7pWdmTsrdIKs++HvmlyFzmXYT54qwXFO0ecAJk etXjQkTPgnjLt9xWajIVxPPDimExt4xQRSkAFmfT6bWWs/jaAMlSf8Yw/jMyOgQD2q VhogGwzoWYxhg== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 3613A10C535; Tue, 21 Oct 2025 17:58:58 +0100 (BST) Date: Tue, 21 Oct 2025 17:58:58 +0100 (BST) To: Edmond Dantes cc: Larry Garfield , php internals Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 In-Reply-To: Message-ID: <4e62d98b-24f8-166f-0ba0-0c65f8b06ec1@php.net> References: <14f591d4-aa1e-49dc-bc20-03cb493dc20c@app.fastmail.com> <4f9b8dfd-5415-3df3-fda9-33a8716c57c1@php.net> Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1226881089-1761064772=:4580" From: derick@php.net (Derick Rethans) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1226881089-1761064772=:4580 Content-Type: text/plain; CHARSET=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 14 Oct 2025, Edmond Dantes wrote: > > It's vastly improved from the first version back in the spring, but the= re are still numerous footguns >=20 > Which specific footguns? $scope var? >=20 > > Mainly, we should not be allowing anything but structured > If you always follow the =E2=80=9Cnursery=E2=80=9D rules, you always have= to define a > coroutine just to create a nursery, even when the coroutine itself > isn=E2=80=99t actually needed. > That=E2=80=99s why we end up with hacks like =E2=80=9CTask.detached.=E2= =80=9D (*Swift*). And > *Kotlin* keeps trying to invent workarounds. >=20 > **TrueAsync RFC** takes a different approach and gives the programmer > maximum flexibility while still complying with every principle of > structured concurrency. > At the same time, the programmer gains two styles of structured > concurrency organization, one of which fully matches Trio. >=20 > > I very much want to see it evolve further in that direction before a vo= te is called and we're locked into a system with so many foot guns built in= =2E >=20 > Such an approach would require more changes to the code, and I don=E2=80= =99t > see how it would protect the programmer from mistakes any better than > this RFC does. > Of course, the with-style syntax would allow for maximum safety when > working with tasks, but that=E2=80=99s not an issue with this RFC. >=20 > The **Trio** model is not perfect; Kotlin and other languages do not > adopt it (maybe by accident =E2=80=94 or maybe not). > It=E2=80=99s not suitable for all types of tasks, which is why the critic= ism is valid. >=20 > Although Kotlin is criticized for storing Scope inside objects like: > =E2=80=9CLong-living CoroutineScope stored in objects almost always lead = to > resource leaks or forgotten jobs.=E2=80=9D > However, there is no other way to solve the problem when coroutines > need to be launched within a Scope gradually rather than all at once. >=20 > But... Ok... > ```python > async def background_manager(): > async with trio.open_nursery() as nursery: > while True: > event =3D await get_next_event() > nursery.start_soon(handle_event, event) > ``` > ^^^ > The example of how the pursuit of an =E2=80=9Cideal=E2=80=9D ends up prod= ucing ugly code. >=20 > My position is this: **TrueAsync** should support the best patterns > for specific use cases while still remaining convenient for the > majority of tasks. > The fact that certain tools require careful handling applies to all > programming languages. That doesn=E2=80=99t mean those tools shouldn=E2= =80=99t exist. >=20 --=20 https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/suppo= rt mastodon: @derickr@phpc.social @xdebug@phpc.social --8323329-1226881089-1761064772=:4580--