Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122320 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29096 invoked from network); 7 Feb 2024 00:55:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2024 00:55:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707267389; bh=N+d1UAh8/RoJ3bAumEkcRXnO+xC/G1pnndgTMPRnt+E=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc:From; b=d3RkqRw8IdzQChv21comTfkrbCr3RHF2t/+nnhVT7S3i53kx7gazJvwL6R82HAY7P yFYLoNyhKF7PPv389AshjFeWgxopUJSp0/udt9BJDhDdDZIX1Hgf8XVdUXi04k5i/9 oYxryCJn31vZnW0SOn9T3cQQP3GuFg+2vkTvOne+KjH/lIr6djoDJuMzAOflFP4v4K +myILa+QNB8xPswZG2p8EWef60vztCGEmv13PaEElPnTq6Oj2Jzsiqmdl/4UaeG/3U EVJo4nq8W3Oi6RkEKq6fT1PSybGwFiF++5fc9NEa06kDdRqT8IdwgPzQQd46mEubvy Po3vLhhEMhn7g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E822318005B for ; Tue, 6 Feb 2024 16:56:27 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT, 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-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 ; Tue, 6 Feb 2024 16:56:27 -0800 (PST) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-60482f88f04so1355417b3.0 for ; Tue, 06 Feb 2024 16:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707267334; x=1707872134; darn=lists.php.net; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OGFUQdjoQG0Ny1qjSOq6afDAT09nJdMSxLtr59id+f0=; b=NzSh1zpfsEDtM/0MfiV+XeUqDTQKBPyuMXmgncdopJSQ1eUZdsFNDpOjaLR6RAewp6 d64AfH4fl3sCAgQdXzR/mMyz0/MGGEMB1YEWHJQabLyUpp6qMd/UqWDhyhAkLZfIMWxO D17kc4g7r3lqgKyeBqilbvgHZhEHcO2qtjzMitQ/FHZgyJypqyfqeLuyiH5Xg8L24z67 gbD1jq3OsvdSgyblg2HLfMmGPHyCMzi/pLa50TOYtnaOeL6PPTCLKyaqix+lwAnO8gCj Dbm2OF09Wy6B1zsDQ6Z3ySIH5Xp4qChuTpxAJLZ8skgPjhwewEPch6wo9pBhOp3FvpCW T0CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707267334; x=1707872134; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OGFUQdjoQG0Ny1qjSOq6afDAT09nJdMSxLtr59id+f0=; b=LsCr0e6QVu5/OHP+vga1V1P2Nn//kuq52m44HUB+kgop1CSpyZMTUMPwNu/FjQIkVj nJIG690sn1blrr3twn448NokCzrvroyY088piZ5c8ROpR8weCtgVqW0xXtX8wkXY0a1i JNHk9dljxt1uZKWkqc5BoXEn9/TWE9C8FLTQgMQYyGDYYHH4KM2X6AUiJqYnHaAAADNm hwiauQ+pl55D7mMxmpaJL20yLmJL9CBEF/zhyJX5BaYCj6YrIl/ICrLaXZCggdeSq5kZ eykYwaeVwm6aFaDpKbqdrTYoEnX66Q46+KGQYGXo0Pl3YEvDtVWpRnOxO8CYB6aJaHnt wS6g== X-Gm-Message-State: AOJu0YycToy0b2YnZ9BZtfJjEG236Uqg3IxsWv4dHmDjOSw21m6kq1nl 7GdKu7ZrF/BCy/Iq894oyUrVNhitQcsLg4q5hv9uFNQkraq6xdETDLVD4Xt4YH8dZIpne8fFQMq eb2y11rqfwzeIJvhXl0TgUV+qD48= X-Google-Smtp-Source: AGHT+IHzCD5sGsCPR3MaOz0NRUw3yly/sJsaXd2jIJM307HT8M2fM7TBHIHaUrePhZl6wX94p4J7b9yovBgC4I0w5ig= X-Received: by 2002:a25:6810:0:b0:dc7:1657:3a6d with SMTP id d16-20020a256810000000b00dc716573a6dmr3275529ybc.13.1707267334196; Tue, 06 Feb 2024 16:55:34 -0800 (PST) MIME-Version: 1.0 References: <742f202d-7990-4f51-b903-7a15e3fd33c2@app.fastmail.com> In-Reply-To: <742f202d-7990-4f51-b903-7a15e3fd33c2@app.fastmail.com> Reply-To: autaut03@gmail.com Date: Wed, 7 Feb 2024 02:55:22 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000fdd21e0610c026c3" Subject: Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301 From: autaut03@gmail.com (Alex Wells) --000000000000fdd21e0610c026c3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 6, 2024 at 7:14=E2=80=AFPM Larry Garfield wrote: > These two samples *are logically identical*, and even have mostly the sam= e > performance characteristics, and both expose useful data to static > analyzers. They're just spelled differently. The advantage of the secon= d > is that it could be implemented without generics. (ADTs would be an > optional nice-to-have.) And if the caller doesn't handle DivByZero, it > would try to pass it up to its caller, but being checked it would require > the caller to also declare that it can raise DivByZero. > Let's assume that the developer knows the divisor isn't 0 - through an assertion or an `if` clause above the call to `divide(5, $divisor)`. In this case, DivByZero error cannot ever be thrown (or risen), but the developer would still have to either handle the error (which will never happen) or declare it as raisable, which in turn may require also marking 10+ function/method calls as "raises DivByZero". Both options aren't great. And even if there was no assertion about the divisor, maybe the developer's intent is exactly to ignore that case as an "implicit assertion" - meaning instead of explicitly asserting the divisor value themselves (through `assert($divisor !=3D=3D 0)`), they rely on `divide(5, $divisor)` doing tha= t implicitly for them. If the `assert()` fails, then nobody is expected to really handle that assertion error; it usually bubbles up to the global exception handler which takes care of it. If the `divide()` fails on the other hand, checked exceptions would require all the callers to actually "check" it by catching or declaring the caller function as `raises DivByZero`, but this doesn't bring any benefit to the developer in this case. So I assume this is why Java developers hate checked exceptions and why Kotlin doesn't have them. I'm not aware of other implementations of checked exceptions; there may be other, better versions of them. If you have any in mind that overcome the issues above, I'd be interested to look into them :) --000000000000fdd21e0610c026c3--