Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128901 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 59DEC1A00BC for ; Wed, 22 Oct 2025 12:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761137876; bh=r/CLnndZXw8Gbw38ZBhjj4BhKKHQxCFW6faOdmzGMZM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HGumKNhNCja920GRUQ7FG5TT8Wk2t9ciuDQvZVcBYQsZkYALFJN4LfQ36ceMZi4VK FN2m1kxaNGuLyb1ijkflJph1QTXFILewoRBDRI7YY+j3vfkeWFNfKVBrOvg2YRQIF7 cA8ZRNCPS9hbGTstZsd/NJoD9oC7lZo/iq4548cLbNz28xTA/i304bRJxBkX8mdhaV LFSEGCbB4M1c5mLJlTwg5/EAfZcz4UbjY2131Jt6QJb6H+M5e2qXAWnZwoD0gYN7NP c6krpLEgJPhtjbntRCIyXyzGINORKD9SUiwyd4JM3BLsJZ4rOZ9zKQhKiYIBOMtcBJ ZwE8zKdYEUbXQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4196A180087 for ; Wed, 22 Oct 2025 12:57:53 +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,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (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, 22 Oct 2025 12:57:53 +0000 (UTC) Received: by mail-ua1-f43.google.com with SMTP id a1e0cc1a2514c-9310a7b2668so1824861241.3 for ; Wed, 22 Oct 2025 05:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761137867; x=1761742667; 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=1f7K89G/hUbhAxsz58LdZYG6uIJsWZwt1u3dYFALCM4=; b=LrdvDcpP+AauM6pAnM3bjgXrjQPr+93dpLBuWOBgrAGXKRqSHcNDSJSyEPS3i4puQ8 qY6wK/vjsqMnwEPYX7GZr7pQkCrvbbqsGcgcRWxdrtRrTpgN0oHyyaUBcIAhZFONUFQ6 I71SHFNmhl1ckdSF2TZVRzTv+a2X1CepgJXnQkNst149cl7GaGgxFcV/id5IYAGnFCIZ 9/qBRez9OWT/njmj0Ed4/DsfqpLg0I+EGqWu1QKYAmYuhHYMv3eXlxMMPvl0fjetYz7g 19IQCRipIk2cFGFFWg6PRAyNVJ5rkC+c9vq/R087ijHeCFQoxjEtF3C6Y0xoFQWoJ5hm rbJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761137867; x=1761742667; 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=1f7K89G/hUbhAxsz58LdZYG6uIJsWZwt1u3dYFALCM4=; b=rsYQvwWeCJettWHS1Xm/Sat1VM9eP1xtawQ9arxUJkS2tuBMKRBQIHO5Rqcmd0x6UL 0JYdGZifydsRqz0D//ENdn/WAO+2aP14gicv++R5/tl1tV6N6rg02l/x3/UOvl/MfbM5 PPRbBHh/jrz7hb8KiC/lRjiZSkQgJHGTz7jcMlpOyKGzPDl1B01etrg8L1+FSUrZ1jXm +OENTGnCcTq6LKs2KNx3Gj3pmH1KwzxqYQbsXO/rrr64uas9jnnMGwXvwGF2FQTN7B+H 2QHOcGEHJEf8JCy65ZaScRHmR25S6MVr8zgGfzipXX9eQ4mBD6JYHTnOMH5xIMdzztKl 9vSA== X-Forwarded-Encrypted: i=1; AJvYcCWbDMeHDgQD2LNVJ9nPBuj4i1bjMV3rk3ugCg6YDLPqzgLPueJRq1Jsf0IKjJ2oleSxlL3tZWydUBw=@lists.php.net X-Gm-Message-State: AOJu0YxxkY/kbHaRzUF76VGwaKbIKh8By0pLhI7FIRpzque9LtfLGpnY vlo0P1LjnjGRuG6YrPxquBW5ZCyOSvCyKS+1JZtfN1kM92AjJrjUIewjgr4OIj40VlpdNOjE4N2 G7vdMpdAjLu+3ss/8DzX+nGl+Y14ezK0= X-Gm-Gg: ASbGncsTc0kWpYwZuiCz0O2fuZqZBVb1dvPJHMvQRD9BzFeLa5EJR5Xrjox4rWHxXEW KeBec/ZfeaKZC0kgqPyMtNSzM5ZVcl7qqnQSstps+cQ1e/tvyrMn8uanAwpp78AJsUhFj81nBcq GA1l2w649e5iWe0uzeysVlimMOUfD7XgRHggF9bFyLQ5H+N3UeZErEde29WgOL4hEk5D2/nf2oT S55PL9I89ReYkH5fwFReDUKWUI0ufLt4wgHExE9+xRp3UFtOSXS4puUS3KP0qlzJSLR8bLLZdJo axY2wF0huj34oKI= X-Google-Smtp-Source: AGHT+IGHLU75yn/Ms+STepE4PajMTplEn0yT6chQfED2aQxuF4ENZ+Qwh8rLGDqNvy72Sue1tOV5NnCrvKkXGcdJ3SQ= X-Received: by 2002:a05:6102:c05:b0:5d5:f6ae:38d2 with SMTP id ada2fe7eead31-5d7dd6f4c0dmr5718133137.39.1761137867005; Wed, 22 Oct 2025 05:57:47 -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: Wed, 22 Oct 2025 15:57:35 +0300 X-Gm-Features: AS18NWDGNtvV9TKBWn9EZqgvJK3Mvat5Y9DOAINU_WThMer-p5X4mjB67SQuH1Y 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) > > If you await a value, everything works, but then someone somewhere else a= waits the same Awaitable that wasn't actually a "one-shot" Awaitable, > so now everything breaks sometimes, and other times not -- depending on w= hich one awaits first. > There is a function: ```php function my(mixed $i) { return $x + 5; } ``` Someone called it like this somewhere: my("string"), and the code broke. The question is: what should be done? Do we really have to get rid of the mixed type just to prevent someone from breaking something? If a programmer explicitly violates the contracts in the code and then blames the programming language for it. So the programmer is the one at fault. If someone uses a contract that promises non-idempotent behavior, it=E2=80= =99s logical to rely on that. > 2. memoization becomes an issue The same question: why should the code work correctly if the agreements are violated at the contract level? There=E2=80=99s no element of randomness here. 1. A person deliberately found the Awaitable interface and inserted it into the code. 2. They deliberately wrote that function. So what exactly is the problem with the interface itself? > With a "multi-shot" Awaitable, this is not practical or even a good idea.= You can't write general-purpose helpers, at all. In what way are generalized types a problem? Why not just use the contracts correctly? ```php function getOnce(Awaitable $some) { if($some instanceof FutureLike =3D=3D=3D false) { return await($some); } static $cache =3D []; $id =3D spl_object_id($some); return $cache[$id] ??=3D await($some); } ``` > 3. static analysis I really don=E2=80=99t see how static analysis could help here. What exactl= y would it be checking? > 4. violation of algebraic laws with awaitAll/awaitAny And the fact that awaitAll/awaitAny are designed to correctly handle Awaitable objects? I=E2=80=99m not aware of any such violations. > 5. violation of own invariants in the RFC Can you show which statement of the RFC is being violated here? What invariants? > 6. common patterns aren't guaranteed anymore So JavaScript yes? ```js class NonIdempotentThenable { constructor() { this.count =3D 0; } then(resolve, reject) { this.count++; resolve(this.count); } } async function demo() { const obj =3D new NonIdempotentThenable(); console.log(await obj); // 1 console.log(await obj); // 2 console.log(await obj); // 3 if (await obj) { console.log(await obj); // 5 } } demo(); ```` Other cases generally have the same problem =E2=80=94 a violation of the ag= reement.