Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128923 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 03CAA1A00BC for ; Thu, 23 Oct 2025 07:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761206365; bh=mlW2bRmH4qW5YGy5VXYjOVXhKYRck+WibY7AX3ZxBaQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RkS24/vQaRvLnHo0JH/KdeuQKncD9vu4JqL/jAjmf9iStMoQT9b9O9Fk9kmB0bWs0 CU8/G4mPkmwVPL5ahr/pU5+0xrnlPC2KSkGJGqTg++dahL0cb8ghxNpoEumE/W+WHW 8u96o7FUXP1lsG2II5rkIBgbKIbfHgOrOde7lp9vMZSi35pp1/XCoyw6r1W2KCGUa7 wTmiGGl/ZksZv4i3TVcMJ8KSNFl1bqUGDXZjlHrw5XoewARjLWjsAs/45EZHf7PqLd 7ub7g2goNos+zqE7qLmu8+qNVQWCWXJXRTWqmC8fd8jlA21fgWLWz1loYZfpp9WUtC AD6Okrv/Y8t1Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D294D180212 for ; Thu, 23 Oct 2025 07:59:24 +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_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (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 07:59:24 +0000 (UTC) Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-59f64abbb61so234417137.3 for ; Thu, 23 Oct 2025 00:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761206359; x=1761811159; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2n7YtnG12IjXPZhIa0KgiclQ4fqq3/Gw6Jcgz3xHmsU=; b=eEfTZxb5uHNb0n/wH6ffytgd/UYic21M68ymQYRnfjkeLwlAK3r3WsWPY1NDNBvVvp vM0s7B01ZYYHjfF/C2eGj1katafAi9uzip4vHOOhwSlXVyqtCDyvLSXIfSSgkKwCflXs JS8pI5PVchJALvRVFHFSq56HNFWW/4gsQDPeH7t5uWetatGTWl0yzfJDEwiPf9HxpEBT FDpkXXUYvgu7Pu6DeQieSgoP2/kawlehy8+rlou5NKEveGA3yX76J305NdMgTJKPgODU vInjsSHg0FkBZczKVFLSBEJWDnUmbBimQd/U/7ihEUFhOPSX8YAO8SVX0Z91jlWXd3ht +95w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761206359; x=1761811159; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2n7YtnG12IjXPZhIa0KgiclQ4fqq3/Gw6Jcgz3xHmsU=; b=QNSsMUFEfI/ZqmeBaA+IGMGRJhkODS+zWqtKh5Qhma6+sTmlwIQ6a+u5ZmDa9rZukR 5lTKzQrmVvEOZGlS5svQM23yucRPQ7+Mbn/G5q4OwmSzcWx+7yujPpHa4a2rF2hl7o2h 3yt6ksWGM1DfblTQdW/JCFaboeg82YFp3IFK0xjpiGdX+LLhVoQWLJPlwpFrqRIc1kV3 1B6stxzhsS42vhDnH3KbNp/cAAMogBkg4doJkgI0dL/y1YDb3CfNtEpvWKOYp9+NrR6e 2lFqib83uoIpqNGK/gyXd60bIzxTxisN1r9olbOWene5qeGMfAgyWRAb5kamtuRbv6ju mxYQ== X-Forwarded-Encrypted: i=1; AJvYcCVgvC0392LpdYQiy9R1wwLPGei6G6Yc7mNPwZkDu6W/zq4XZ6kpPgJZs/Y/oEnZc/D++vJdx2VSOSE=@lists.php.net X-Gm-Message-State: AOJu0YyTR9Dix9Clgj+UXmzhYLjbhgSjvCan1QudBCI5BNohaN3z/nxt 8Itf98+XEN8ApQekOy90VNp2yFToNL5mlCtIpKjPUV3wg7L0leUAU8sdJMWCKi/1Tx+B3uPc494 qY4QWqLX8/wc08vAHf2uQdhMwerozIwIbIrCudec= X-Gm-Gg: ASbGncusdHRJPtEL5mK/BzYSd8hKilT7kXZSaEr2Sr9hucJYJaCgMXVFmG0qfiiBAiz RbuQrNXFKSoFqP958tyJtNap5zptEWpp3WoWuW0eFayk0B85SRhJ8rbaHTJXTzr9PoQc32ChBaI qaxSgTWTnan5eRLPeGFyErgAksHo+kG5KiHM8gCRrf7gJARxyd26jt+hLb3YuG5Y/c4c7LM3+Z0 OFYqT/Nua4d7/t2Dm8Vc7X+/xgYDXbZ0I6PYPMyXcpBpjj/9ZZGjFcbBli1O5NJnUqQY6jy4y1k rAACVJ3jEz7uOmbYCaWsE+u1BrELBoNpzbhX X-Google-Smtp-Source: AGHT+IFS1JZF+ai2HqsvmfMEFdXiF4n4VpfHBONsXyN8lhhpt3WbUKT5c+j2sThw21XBhBdJA5KcU1C/lDuTeQ+frOs= X-Received: by 2002:a05:6102:26ca:b0:5d5:f544:a88e with SMTP id ada2fe7eead31-5d7dd5ec4e3mr7128986137.35.1761206358757; Thu, 23 Oct 2025 00:59:18 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 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> In-Reply-To: Date: Thu, 23 Oct 2025 10:59:06 +0300 X-Gm-Features: AWmQ_blXvStfmb9yCgfZupujaS29GWoZVQiqoWoLYqBssHcyaxFiCl-4FndNIOM Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 To: Rob Landers Cc: Aaron Piotrowski , PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) I=E2=80=99d like you to have the full information necessary to make an informed decision. There are two or more channel objects that need to be awaited. How should this be implemented? Currently ```php [$result1, $result2] =3D awaitAny($channel1, $channel2); ``` With Futures: ```php // Like Rust [$result1, $result2] =3D awaitAny($channel1->recv(), $channel2->recv()); ``` Rust: ```rust tokio::select! { msg =3D channel1.recv() =3D> println!("Got from 1: {:?}", msg), msg =3D channel2.recv() =3D> println!("Got from 2: {:?}", msg), } ``` Swift: ```swift async let result1 =3D fetchData1() async let result2 =3D fetchData2() let (r1, r2) =3D await (result1, result2) ``` Although both Swift and Rust create a Future under the hood, that=E2=80=99s part of the internal implementation, not the user-facing contract. 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 awaited. When executing the awaitXX operation in a loop for such scenarios, the programmer will pay for the visual clarity of the code with extra operations to create a PHP object. Are you sure this is what you really want? I want to caution you against directly comparing PHP, Rust, and Swift. What a compiler and zero-abstraction languages can do, PHP cannot. And the approaches used by Rust or Swift cannot be directly applied to a language without a compiler. I have no objection to doing it the way you prefer, but keep in mind that chasing what looks elegant often leads to poor decisions. It=E2=80=99s better to think it over a few times.