Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126839 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 62C551A00BC for ; Wed, 19 Mar 2025 11:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742384924; bh=dirt59tXVaCBxrPoZiTka/m3wxKi7ptvawkDOcvg0mM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QlEiIBuuPv3P1VnJCdjD3UMlkiRM9nIiRIxebyXsEJKQ+gL9xhonHobX5pBLreeyR pSX6wja4XFe6WOWVW5yFpQ2WLcr+uNlJQIBDrPa86UAodmmujk+mEA3G4Ar/RWUt47 KUbYMOJ6w2PDvS3wbNrnwrsb6HPs1n2BBdVtD5oVyfRg+2ScEMPa6+8rLJSf3Kgj41 i2Ly2PoWvfmqwm6celFiOZi5IOd6LizahKi1WvR876SFeBt6bLIAt+LDBzjOSMLvoI TRhhHHkON38pruckGyEmRSukr9raeYfPZrCMbhY87QBx1uwCIdxDsBl45DDESi8jhW YH8nQxVQjMYCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2D1A41801E9 for ; Wed, 19 Mar 2025 11:48:44 +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=-3.9 required=5.0 tests=BAYES_00,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-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 ; Wed, 19 Mar 2025 11:48:44 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e643f235a34so1858256276.1 for ; Wed, 19 Mar 2025 04:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742385074; x=1742989874; 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=MdtRnQMSR5TEJgu/1XHbrv7eOhTXLpzEN4K+6asN0T0=; b=DeGJH5Ws6g/s5alOQB6cP9gsREx8YFJ0Jui0df483m8IyBc/R4NnjV4rrWxL+dnTXl E3CUt2aJgcseqm5ucrq4jP40kOSilMnoN61Ou/+NagfhObbk4YN1nJx1xdCM5jMTOZAs URj+a3qMN1Hiy/ewa4fBxaRMYqDnQ1Nqb4HVc1BF9aEha1do4zBFvaVGHVmEQqBypQgz hA2i+dVfGTZot/+rNFZtaYqof7CGJS3VxKlcn/4L8S7JQupzub+KDxVCN/eugKtHQd7W 6xzXT4NGIBjp2+cAMPWlnaDSYSh8iWaM0fuym/VXS7tkAV61wOK/6haoMpgPoPCwoJ3p /fjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742385074; x=1742989874; 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=MdtRnQMSR5TEJgu/1XHbrv7eOhTXLpzEN4K+6asN0T0=; b=tu4I0CZNL/G2wGyjkyspHCbFqp04+A3EraHq5IaYV5cMAxK/rX6hUCPRmUbqshuqPz 5jVxBM9DXa3UBDyWwC81BY/sWGl8eW2Njx8WQ0PTFMpyT50sw50nQM2m2wc6IooGt5KS s6mF4Pe/M08lPkXh5H8bKRIlkeq4MV+FjPKqpX1It1Pj6hM8sf3NJek3WrAlJAk0Gc4d y/w2/iBFQ+s3EsMhsJKWe6oGo+OT6L0Y/KctVbfSyvBKdRY7ma8r7yHxjSPvHXDMrqO6 cs9s9siWXxaAWVz+0BXzS14dB3zxtZpNqFZ3Mi43WPoB8TKlszA2QuLfKU1douUIovfJ F2gQ== X-Gm-Message-State: AOJu0Yz3+bEaxy6a1ZsQSXxYVqX4Qv8FR3zJjTPabJBAbEVnoui+Y1dr 2aqwSPDy6lnc0k5gCWERptsMiYfex1ij0MAP/w/cqEwgNQNQxMtUtMnPETVH1gcCFStw73mW2kg UjHsDN8dbtSuITHN5cvWZvzGsKexIqqAL78QYKg== X-Gm-Gg: ASbGnctVYn+OGZKsMbJ3RKFuvWxMt9ECI7/Jz+NlsOmLL5GqgXzGnmtCO7HtGPeFYFE eMcQGNQf6OxxSWcHwholMMwE4oaLTIyBJ4mGuQTgY3khQ6HnfxOjS3JV9v68aDmoRYWIm4H0s/s nY6PXeoAAdq9ld6kK2T8cZenlr9g== X-Google-Smtp-Source: AGHT+IEWV8nUmuWFXXK3NSLRJIyXKIX+WqmQ+QRzdwFSgwvpoWcW0YNWw2JkDAvxvQ3/jAtsAmh8raBg7P3If0GEM+c= X-Received: by 2002:a05:6902:1a4a:b0:e63:ec1a:3ac4 with SMTP id 3f1490d57ef6-e667b39f6c1mr2874519276.3.1742385074476; Wed, 19 Mar 2025 04:51:14 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <258a9a97-7c86-44dd-94bf-a397a84300aa@app.fastmail.com> In-Reply-To: <258a9a97-7c86-44dd-94bf-a397a84300aa@app.fastmail.com> Date: Wed, 19 Mar 2025 13:51:03 +0200 X-Gm-Features: AQ5f1Jr8Ddp5skKm7FSpgD_hk91pIkVoujq5UWP9bZEVSFgDaeNcHECR4thXJo0 Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC - Stage 2 To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000006d258d0630b0a302" From: edmond.ht@gmail.com (Edmond Dantes) --0000000000006d258d0630b0a302 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > Generally, RFCs are for changes in the language itself, not for API contracts in C. That can generally be handled in PRs, if I understand correctly. > I thought this was handled by PHP INTERNAL. So I have no idea how it actually works. > > or other weird shenanigans? I think it would be better as a statement. > Your example was absolutely convincing. I have nothing to argue with :) So, `suspend` is 100% an operator. > > What happens if it throws? Why does it return NULL; why not `void` or the result of the awaited spawn? > Exceptions are thrown if they exist. This also applies to `suspend`, by the way. Why not `void`? Because the expression `$result =3D await ...` must resolve to something. If I remember the core code correctly, the PHP engine returns `NULL` even if the function is declared as `void`. > > Wouldn't it be better to throw an exception instead of silently failing? > Possibly, yes. For me, this is a difficult situation because the code inside the final handler is already executing in a context where any exception can interrupt it. > > Hmm. Do you mean this literally? So if I call a random function via spawn, it will have access to my current scope? > Exactly. And yes, accessing a `Scope` defined in a different context is like shooting yourself in the foot. That's why this possibility should be removed. > > I know I have been critical in this email, but I actually like it; for the most part. I think there are still some rough edges to sand down and polish, but it is on the right track! > In this RFC, I made two very big mistakes due to attention distortion. This once again proves that it should be moved forward very slowly, as it only seems simple. The first major mistake was that I tried to make functions an element of structural concurrency. But to do so, functions would need to have an `async` attribute, which contradicts the RFC. The second mistake is the `currentScope()` function, which doesn't just shoot you in the foot=E2=80=94it shoots you straight in the head (just like `globalScope()`). Of course, a programmer can intentionally pass the `$scope` object to another coroutine, but making it easier for them to do so is madness. --0000000000006d258d0630b0a302 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>
>=C2=A0 Generally, RFCs are for changes in the language itself, not for API contrac= ts in C. That can generally be handled in PRs, if I understand correctly.>

I thought this was handled by PHP INTERNAL. =C2= =A0
So I have no idea how it actually works.=C2=A0=C2=A0
<= br>
>
>=C2=A0 or other weird shenanigans? I think it would be better as a statement.
&= gt;
Your example was absolutely convincing. =C2=A0
I have noth= ing to argue with :) =C2=A0
So, `suspend` is 100% an operator.=C2=A0=C2= =A0

>
>=C2=A0 What happens if it throws? Why does it return NULL; why not `void` or the r= esult of the awaited spawn?
>
Exceptions are thrown if they= exist. This also applies to `suspend`, by the way. =C2=A0

Why not `= void`? =C2=A0
Because the expression `$result =3D await ...` must resolv= e to something. =C2=A0

If I remember the core code correctly, the PH= P engine returns `NULL` even if the function is declared as `void`.=C2=A0= =C2=A0

>
>=C2=A0 Wouldn't it be better to throw an exception instead of silently failing= ?
>
Possibly, yes. =C2=A0
For me, this is a difficult si= tuation because the code inside the final handler is already executing in a= context where any exception can interrupt it.=C2=A0=C2=A0
>
>=C2=A0 Hmm. Do you mean this literally? So if I call a random function via spawn, = it will have access to my current scope?
>
Exactly. =C2=A0<= br>And yes, accessing a `Scope` defined in a different context is like shoo= ting yourself in the foot. =C2=A0
That's why this possibility should= be removed.=C2=A0=C2=A0

>
>=C2=A0 I know I have been critical in this email, but I actually like it; for the = most part. I think there are still some rough edges to sand down and polish= , but it is on the right track!
>

In this RF= C, I made two very big mistakes due to attention distortion. =C2=A0
This= once again proves that it should be moved forward very slowly, as it only = seems simple. =C2=A0

The first major mistake was that I tried to mak= e functions an element of structural concurrency. =C2=A0
But to do so, f= unctions would need to have an `async` attribute, which contradicts the RFC= . =C2=A0

The second mistake is the `currentScope()` function, which = doesn't just shoot you in the foot=E2=80=94it shoots you straight in th= e head (just like `globalScope()`). =C2=A0
Of course, a programmer can i= ntentionally pass the `$scope` object to another coroutine, but making it e= asier for them to do so is madness.=C2=A0
--0000000000006d258d0630b0a302--