Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118146 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48858 invoked from network); 1 Jul 2022 03:53:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Jul 2022 03:53:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 60134180089 for ; Thu, 30 Jun 2022 22:45:09 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 30 Jun 2022 22:45:08 -0700 (PDT) Received: by mail-ua1-f53.google.com with SMTP id x21so483898uat.2 for ; Thu, 30 Jun 2022 22:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vb8XoHozBPOA15i7AqzMoBN/yld3kRxrQ5HMHbBaHdA=; b=pcJR+UkBi73PS54s14SNDItC776ya63PNHNuArm5rdPqE8mAG6J21ZDX9zJ6uNAyUM AKU2J0FcMJqY6UVKSbi8b/QgjjEKzLUXmIqVFmEiyiEvO2RONI0FaMTclkKGkdUBIw9s 62nMPCpJ1xyIf8vE/PqupM7Li8fZNLbauwUXSfgJQvip8R2rPgvHLiMyXXQI+evwUpZu eZnJ412uQHJzNoM8VBVPu9vEAM4zUOxedLcfNC+ExvML99/GHAXFHZHvgUb+kasc/4Y3 +QWaxIU1xoYttWrZpM9Y/xL+/B1V9xm70WkmPLSN/XQW6nCyOZn7PwQPMGF4Q8DSAxd/ Yvdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vb8XoHozBPOA15i7AqzMoBN/yld3kRxrQ5HMHbBaHdA=; b=4ejO54AzrOYeXZai+LL+OrWyPMpSgKlrLSPCoJb0z0wfftf7VU1QUZsdmwtRBTFnYM udQeaT2vacpvrJsaJ7MN5IZmRqWKCmdfA7hGzekfkyauNQfVcfGkJC1sFaBXhJbnAdyf s12ua6DyN95aZSEQ/Exqk4+Fszct24jMqQXD05ZL8XnZ0rDOydHFyQpvu3xMBD4ZGVCM +EYkljWt94ZPrW4WS8ouO+oFfB3vapaEp1ryWH+tCqCEK+w7xvMGbEGFH36Zj7ArcXcV Cya6x53cRvVCRZdX/Zfjl70ln1DTKOlglPPnqVT2qxfo33o6KdOQTsNCv2Q6ky0rTKBc AKpQ== X-Gm-Message-State: AJIora/oUphzOwFZLYOeLCHYuL5A99Y4QbrXmqXmSSCT5YyEkSLJfJmx xEZfRzyshQqkWHOYaiaAyZILHAS8SRQpoQ2jBat8nKil+4Ho5w== X-Google-Smtp-Source: AGRyM1uiE0MA0orLWf0xOL8jlRlnYULtnfZRwp7+N/nZBdi7X9hLUofqFLa0NojETtOiCRD45+hS/Z5lOYVHpllk8pY= X-Received: by 2002:ab0:388e:0:b0:37f:3dd:76da with SMTP id z14-20020ab0388e000000b0037f03dd76damr7512799uav.26.1656654307905; Thu, 30 Jun 2022 22:45:07 -0700 (PDT) MIME-Version: 1.0 References: <982FFD13-6B2C-4A28-8091-886F2F637B86@me.com> <3a4338fc-5767-4b1d-a584-95e2ecb82572@www.fastmail.com> <448645c78da44675ac3434df3384f815@fsx.com> In-Reply-To: <448645c78da44675ac3434df3384f815@fsx.com> Date: Fri, 1 Jul 2022 07:44:57 +0200 Message-ID: To: Jeffrey Dafoe Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="00000000000089d60005e2b7e301" Subject: Re: [PHP-DEV] [RFC] Exception type hint From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --00000000000089d60005e2b7e301 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jeffrey, czw., 30 cze 2022 o 17:41 Jeffrey Dafoe napisa=C5=82(a): > > -----Original Message----- > > From: Larry Garfield > > Sent: Wednesday, June 29, 2022 12:39 PM > > To: php internals > > Subject: Re: [PHP-DEV] [RFC] Exception type hint > > > > On Wed, Jun 29, 2022, at 10:42 AM, Guilliam Xavier wrote: > > > Hi (note: your message was flagged as spam), > > > > > >> https://github.com/php/php-src/issues/8843 > > > > > > So I understand it as having a "true code" equivalent for the > > > `@throws` phpDoc comment (similar to type declarations for `@param` > > > and `@return`)? which would also be checked at run-time? > > > > > > Just my 2 cents on that (let's call it "exception specification"): > > > > > > 1. IMHO, it shouldn't be mixed in the return type declaration (with > > > a union-like syntax) but separated and independent (e.g. with a > > > `throws` keyword, and pipes [or commas] between multiple exception > > > classes) > > > 2. AFAIK, Java has it (mandatory to compile for "checked > > > exceptions", sometimes controversial), C++ used to have it > > > (runtime-checked) but dropped it (and introduced `noexcept` instead); > > > I don't know of any dynamic language that has it > > > > > > You would also need to define how it plays with inheritance (and > > > reflection), and what exactly should happen when a function throws an > > > exception it didn't "declare"... > > > > > > PS: I also found some old feature requests: > > > - https://externals.io/message/4424 > > > - https://bugs.php.net/bug.php?id=3D42251 > > > - https://bugs.php.net/bug.php?id=3D62404 > > > - https://bugs.php.net/bug.php?id=3D67312 > > > > > > Regards, > > > > Side Note: Please don't top post. > > > > On the subject of checked exceptions, I *highly* recommend this writeup > > from the lead of the Midori language[1]. It's long, but there's a > section > > specifically on exceptions (no deep link, just search the page for it) > that goes > > into a lot of detail about exceptions, checked exceptions, and the ways > in > > which both fail. It's absolutely worth everyone's time. > > > > The summary for the short-timed is that the only way exceptions work, > from > > a reliability standpoint, is if they are 1) Rare and 2) Strictly checke= d > and 3) > > Have really good syntactic shorthand support. And checked exceptions > > without the other two are a recipe for hell. Basically, it only works = if > > exceptions become an alternate syntax for an Either monad or Go's multi= - > > return. > > > > Since PHP is a long, long way from there, I don't believe checked > exceptions > > would be wise, or even slightly a good idea. Not until/unless it's don= e > as part > > of a global rethink of error handling that reimagines how exceptions an= d > > errors work at a fundamental level. And that couldn't be done in a BC > way > > with the current practice of "I dunno, throw, YOLO" in PHP exceptions, = so > > they'd have to be some other, different channel. We are definitely not > > ready for that kind of fundamental rethink of how error handling works = in > > PHP. > > > > [1] http://joeduffyblog.com/2016/02/07/the-error-model/ > > > > -- > > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, > visit: > > https://www.php.net/unsub.php > > There's also a decent article here > https://www.artima.com/articles/the-trouble-with-checked-exceptions where > Anders Hejlsberg discusses the problems he sees with checked exceptions. > Thanks for the link it was really interesting to see issues with checked exceptions based on someone's experiences. Cheers, Micha=C5=82 Marcin Brzuchalski --00000000000089d60005e2b7e301--