Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126636 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 qa.php.net (Postfix) with ESMTPS id C452B1A00BC for ; Sat, 8 Mar 2025 08:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741422152; bh=iB0C4jaHiZ6HvpGS+qN/+TX/QXI6XV+XCCNZe1xkH9o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nZQw6hfmiRZJmK5+T4UEfY4qzHBSb8sFoYPtr7mXNRy65vJr6yVobVlx0zpTKjVBF MLFFJohsdCp7UdSjb5AKkHQfzuDSPCsotq2vzJpOXRNNeHkWBqCGXJF7E6g8iQPBOl 5HF3THhhmrQtoEcbtYizj/9giP7M2jdnSayNr6opTJjFFm0R8XSKR3v0W0i9/4dPJT dDTEYdi3sCth7HeKf9BZpcfIOFGIKf6ZqkQOqjaAh1KB78/qYUUoHmiMxnHDtw+EKB +PS9wIQNgGk/hPdT/klgwLrEK2+DE/xH+3iKovEJh2j1rQnqe0vMH2Mwd9NIB0URw/ iR3tM+aEwRr2w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9F5881804D3 for ; Sat, 8 Mar 2025 08:22:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 ; Sat, 8 Mar 2025 08:22:28 +0000 (UTC) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e60ad903382so1687874276.0 for ; Sat, 08 Mar 2025 00:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741422303; x=1742027103; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iB0C4jaHiZ6HvpGS+qN/+TX/QXI6XV+XCCNZe1xkH9o=; b=BSS0s+dK4VXaITDW78GhhCoWDOvs2DvWny3PWVJi6uc5LrbBByfccsJiaUPc/3fkv9 8/D9+Chh459fMPksCqCl95EpMwzpfedeHahZ9Ye60Ia4Nvt4yQ78oNlnTfw+FuyCZBgP J1jMdqtVXjGX52/9nPkXENqcSzSjTJtHYuxDHPvxGrRWNsP2pi8Twmi6lTiOhDGaq6rM /T86bIVE5H3rLI4vQFEphN8gAtQVJH5Bz+3GVFQPbLAq+9uB9Tc+lYQKRWjIZ3ilUqiY +FPbBM8/q0+Sk44u0oP5pSR3vnAY2hvsIkzJTl96KAU1gYQcWu+B8o373xul4+dIzBIu IfGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741422303; x=1742027103; h=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=iB0C4jaHiZ6HvpGS+qN/+TX/QXI6XV+XCCNZe1xkH9o=; b=GnaznJT2jRhT7dGQCV8tR8BlaelfOlu0uqbJfed8IDEGjhLbbkOMrQJ00+hH1O0YFU acw8YsBz8Vug7zZQjnVH7Zg4m/sYQrmKtrOxiVDw2sZIUUnZEqE2nbtVHgyxBwRoBivA g/nO0f56u1cr6yD9rPSM4ql2PuFln6GVSQV/JRnhHcsP4VLqLMKnjdU1wDeXpdqzRsw6 8KzeJ2eC9SGQWZvQjIR6fJ6FHR+HfhC3w5isw/n+x3cjGEcfwLxBsF7HvmD3Alnf9dQk 03vTwCrN//jy8rz1hVpYhEn67XVIuZq3iRnTCu+lCUvWsf82CEj1K+W67MILVN9sWqtF +tVw== X-Gm-Message-State: AOJu0YxALB6mhmXUIKbJuBvkMGtXgdkye9yA1rLk2NJfzS6o3RdkfEkl 5vbbNXedVdIkTPr7nEYDZf34Zp8Qcbkz3ZX5Trt9mi3uAJ40F4jskUcOPNrI3UQhOcB2Dzzq8pr 44wWcMT8GL0Hg/9tm7DsVmDgbFUKganLhe3hZmg== X-Gm-Gg: ASbGncvk8OeoKGzvVzdD/9k3kuJAMYq9V5smyux8DhEyLiQEu/6vcSoy4MKZBTSSSA8 1Fwi+4y5cqx2JbTEfKvd/i5N3SngG3CqjGz6wl2KoPooeeMWLNoFQA/ZduiCGGwWGZngeDma1Bp J35Hl0tqzz/GBrNv7vShP/pXT7PA== X-Google-Smtp-Source: AGHT+IFTv/04j37KsQMp1f7RPkmO2Tz1SwvRTqlUW8q/Dig5AHjPVirJA31ohQQqZndRnIp1gCYxEtuX3e75C8gs2q4= X-Received: by 2002:a05:6902:18d0:b0:e5d:d4e3:ad8 with SMTP id 3f1490d57ef6-e635c1a4928mr7959460276.28.1741422303105; Sat, 08 Mar 2025 00:25:03 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> <78a03dd0-fd4a-4f4a-ad8a-37e5704f06fc@app.fastmail.com> <08c8ad0b-e8f4-46e3-99f0-b80748d40b89@app.fastmail.com> <07973EAE-2D83-47A8-8FA0-84286C77C02B@rwec.co.uk> <48d66433-3ae9-4895-8361-7c81a0a3670d@app.fastmail.com> In-Reply-To: Date: Sat, 8 Mar 2025 10:24:52 +0200 X-Gm-Features: AQ5f1JqbQdS6q4ZzO5xzrqCWVBz77OL_seSdpuk9TKwtD4ahB3GHfImV6dF5M64 Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000c7dce6062fd07983" From: edmond.ht@gmail.com (Edmond Dantes) --000000000000c7dce6062fd07983 Content-Type: text/plain; charset="UTF-8" > >for($i = 0; $i < 10; $i++) $results[] = async\async(fn($f) => file_get_contents($f), > $file[$i]); > // convert $results into futures somehow -- though actually doesn't look like it is > possible. > $results = async\awaitAll($results); > Future can be obtained via getFuture(), according to the current RFC. ```php async\async(fn($f) => file_get_contents($f), $file[$i])->getFuture(); ``` And this semantics can be simplified to: ```async file_get_contents($file[$i]);``` or ```spawn file_get_contents($file[$i]);``` From this perspective, I like that any function can be called with spawn/async without worrying about its internals or modifying its code. The pros and cons of this approach are well known. --000000000000c7dce6062fd07983 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>=C2=A0
>for($i =3D 0; $i < 10; $i++) $results= [] =3D async\async(fn($f) =3D> file_get_contents($f),
> $file[$i])= ;
> // convert $results into futures somehow -- though actually doesn= 't look like it is
> possible.
> $results =3D async\awaitAl= l($results);
>

Future can be obtained via g= etFuture(), according to the current RFC.
```php
async= \async(fn($f) =3D> file_get_contents($f), $file[$i])->getFuture();```=C2=A0=C2=A0

And this semantics can be simplified to:= =C2=A0=C2=A0
```async file_get_contents($file[$i]);```
or
```spawn= file_get_contents($file[$i]);```

From this perspe= ctive, I like that any function can be called with spawn/async= without worrying about its internals or modifying its code. The pros and c= ons of this approach are well known.=C2=A0=C2=A0
--000000000000c7dce6062fd07983--