Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113492 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49761 invoked from network); 12 Mar 2021 04:18:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Mar 2021 04:18:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C22781804B8 for ; Thu, 11 Mar 2021 20:10:49 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mercury.negativeion.net (mercury.negativeion.net [199.38.81.6]) by php-smtp4.php.net (Postfix) with ESMTP for ; Thu, 11 Mar 2021 20:10:49 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id F3D2E20CC2BC4F; Thu, 11 Mar 2021 23:10:48 -0500 (EST) Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xoLq0ANc35eJ; Thu, 11 Mar 2021 23:10:48 -0500 (EST) Received: from [10.0.1.101] (unknown [173.225.146.47]) by mercury.negativeion.net (Postfix) with ESMTPSA id 5EDDC20CC2BC43; Thu, 11 Mar 2021 23:10:48 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) In-Reply-To: Date: Thu, 11 Mar 2021 22:10:47 -0600 Cc: Internals Content-Transfer-Encoding: quoted-printable Message-ID: <4C6E346A-9CFB-4930-B102-0C709DF2628A@trowski.com> References: To: Matthew Brown X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [RFC] noreturn type From: aaron@trowski.com (Aaron Piotrowski) > On Mar 10, 2021, at 12:06 PM, Matthew Brown = wrote: >=20 > Hey, >=20 > Ond=C5=99ej Mirtes and I present an RFC for the noreturn type: > https://wiki.php.net/rfc/noreturn_type >=20 > The feature already exists in Hack (the primary inspiration) and is > currently supported by our static analysis tools inside docblocks, and = we > feel there's a good argument for it to be supported by PHP itself. >=20 > Thanks, >=20 > Matt & Ond=C5=99ej Hi Matt & Ond=C5=99ej, I wanted to give my +1 to this proposal. I was curious to see how fibers might interact with this declaration, = since it is possible to create a fiber that can not return. So, I = compiled your branch and gave it a try. ``` $fiber =3D new Fiber(function (): noreturn { while (true) { Fiber::suspend(\random_int(0, 100)); } }); $result =3D $fiber->start(); for ($i =3D 0; $result; ++$i) { echo $result, "\n"; $result =3D $fiber->resume(); } echo "Generated ", $i, " numbers before generating zero.\n"; ``` This short script works just as expected, cool! :-D Cheers, Aaron Piotrowski=