Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122323 Return-Path: <6562680@gmail.com> Delivered-To: mailing list internals@lists.php.net Received: (qmail 48810 invoked from network); 7 Feb 2024 07:25:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2024 07:25:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707290804; bh=Fl7b15Lk1vV9yjl+5KMreAGvzHNYN/rb6Pl8f1vBkHU=; h=References:In-Reply-To:From:Date:Subject:To:From; b=C64UZBB0ibN1Sjg9s1OPrL75hGt7tDgGme/ov72cdN4ugktH1jKD8VLgWgBnPalAi xUe31vOnxSIEDUpqAnaiTlUN8U6taXC30MsiAlCWE+Xh+fc3Uee8FkJZVsT3lwDrCB ox+wVlqmq21iSNNZ9T2TlpsEXhK/hXGE0wTddv0w8AhUV6azteylB/bGayv3DSjZEs 7k+SESWUY6xUDcPZCEYfoq4LGKqWOB3eCUbbkirO9wkNXVG/0NZH1Mu+M346P2Dz2F +/VT1+/FRUq8EwwvnqL8xq67y5vJYyxTHZ2bjzPz8i1x6SfKOO3pcrSrgMkc0yNAwn AtQvmEkOZjCCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1C4DA18006B for ; Tue, 6 Feb 2024 23:26:43 -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=-0.4 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: <6562680@gmail.com> Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 23:26:42 -0800 (PST) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-599fc25071bso189146eaf.3 for ; Tue, 06 Feb 2024 23:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707290749; x=1707895549; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=k2yPXselc5K+5C6orgLpJrTccSwkXL6yB55B4FG79/4=; b=KBxtA1SXU2W/lUm40ICFrKElYTk8Q0IEkEWcCglgLqkqTS6tXczI11YgfZIH7mOhA1 APb8rqsO5jphpe6WO1gbMshUB10lVboVHyppa5Hy5LLwsewpiNZFie2Ne1uIlOOFmxjx miqj1NkXjtycYs2qrAIaSCJOSzb46HG8MJE+wp/0b0TV71hTtJSsdnifcvdHwmunDpUI c60IVxmjpoS2SPbYk5+HundqXksEcGtE6zNnK0Vpz4YCRGY01xEypozDI33M/qotTxOg bAwty7VpLVzOemDU2Atz4Zc7nxl1D8/u0Hc7d5ktOYe9P/DFIcsWxLHhQnFGCNPAZgZn 39oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707290749; x=1707895549; h=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=k2yPXselc5K+5C6orgLpJrTccSwkXL6yB55B4FG79/4=; b=hwRWfaPFLYtvp3+hazSV8n4aI3ZSCXBm+VrEZG/RA+4mup8MmuR/SAihBrvbZzX3e3 Ann1nNNEodLmk0e/zb8t6rAifZD5j910fXci72FZmE87OobschQEiWdB5V4LXuh6ufRJ eYpRWwE6nGw80H6MbEskjqH5V+GT1dEuA6PbCqYLvuqEaKwkcxnWaoAqRMAglUx3k5mb yHSxfyhKCc/D58AgobOPXnN0nxoKp5NpgzOv7GAC73GydnfQzFI1MIBLeTOQrlgs1M1y 1pQrjK9beZm3XEzmrcBtgtGx5qLHNROvmSZRYCQt8q4RjCOBI2C7Aj/Si5jtOTAXvcil DIFg== X-Forwarded-Encrypted: i=1; AJvYcCUBg/IifmT6lc0XBpq5qP+hQJ8akCb1DCGfSS4RCjW85RrQq7W1/+L0MxvGPPf+N2IovNMBXOhbTR9ug7SBqlKkMuorkAg/Yw== X-Gm-Message-State: AOJu0Yy9m/tXI9q7tUHKBARttE5feBb4bKLg7tWX5WBtj/y2srPj7xPv 9/rT8MvQqE2r47Js2mEiGd5RL/3fTWxHLBHEHIQbiyLOfnEN/neh9wIpiayAxz6yJ4l+8IV6QNk +gCf2tu055G1GEIZlSbnjaGbGPp8= X-Google-Smtp-Source: AGHT+IElY7Zx7WCS12fumCShhUA9KE0kX0u5a0QuZE04L0YL3Jr6pfBR2cEv4phPdj4uS3whO24D9pkMhAQf7sPiTPg= X-Received: by 2002:a4a:3402:0:b0:59a:893a:22fa with SMTP id b2-20020a4a3402000000b0059a893a22famr5413618ooa.6.1707290749205; Tue, 06 Feb 2024 23:25:49 -0800 (PST) MIME-Version: 1.0 References: <742f202d-7990-4f51-b903-7a15e3fd33c2@app.fastmail.com> In-Reply-To: =?UTF-8?B?Yg==?= <6562680@gmail.com> Date: Wed, 7 Feb 2024 10:25:12 +0300 Message-ID: To: autaut03@gmail.com, internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000a285490610c59a2c" Subject: Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301 From: 6562680@gmail.com (=?UTF-8?B?0JPRgNC40LPQvtGA0LjQuSBTZW5pb3IgUEhQIC8g0KDQsNC30YDQsNCx0L7RgtGH0LjQuiBXZQ==?==?UTF-8?B?Yg==?=) --000000000000a285490610c59a2c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for suggestion about assert() use cases, i know it exists before, but never used. Usually if something shouldn't happen i throw exception there, or at least type control. Its like manual mark for the future - you doing something wrong, fix it. Error collection case its about "you're right, but external system doesnt think so". Example 1: i send correctly and valid first name (for my system) to external system. That system reported thats name contains character outside its regular expression. I can solve it in-place creating function with regular expression that change invalid chars to question marks and case will be covered. Example 2: My system result is less than zero. Remote system expects greater than zero. I cant just validate/sanitize data to greater than zero. If i send single operation - it could be the exception. But there could be two cases - multiple operations (commands) queue or bulk operation (one command, few rows of different data). In first case i have to stop all operation, exception could help me. In second case same error becomes to warning, and one row should not stop whole process, but have to report me. So previously i solved it with exception, and now exception shots my legs. Thats why i use exceptions only if something wrong on developer/user side, and never to system-system cases. if() still powerful. =D1=81=D1=80, 7 =D1=84=D0=B5=D0=B2=D1=80. 2024=E2=80=AF=D0=B3. =D0=B2 03:55= , Alex Wells : > 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 > same > > performance characteristics, and both expose useful data to static > > analyzers. They're just spelled differently. The advantage of the > second > > 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 requi= re > > 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 grea= t. > > 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" - meanin= g > instead of explicitly asserting the divisor value themselves (through > `assert($divisor !=3D=3D 0)`), they rely on `divide(5, $divisor)` doing t= hat > 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 check= ed > 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 = :) > --=20 +375 (29) 676-48-68 <+375296764868> / Mobile - =D0=BF=D1=80=D0=B5=D0=B4=D0= =BF=D0=BE=D1=87=D0=B8=D1=82=D0=B0=D0=B5=D0=BC=D1=8B=D0=B9 =D1=81=D0=BF=D0= =BE=D1=81=D0=BE=D0=B1 =D1=81=D0=B2=D1=8F=D0=B7=D0=B8 https://t.me/gzhegow / https://t.me/%2B375296764868 / Telegram 6562680@gmail.com --000000000000a285490610c59a2c--