Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122333 Return-Path: <6562680@gmail.com> Delivered-To: mailing list internals@lists.php.net Received: (qmail 89587 invoked from network); 7 Feb 2024 17:29:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2024 17:29:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707327030; bh=6s1193F5nsemk+q5vA4soIantASwmTkXsnm6Ymw1pzA=; h=References:In-Reply-To:From:Date:Subject:To:From; b=JQFrGuZ0XfxNFwrR7uhS57mJSMlx0+kPYfRFko0J1fddj6rcOuN/6zGbFTWMljHMs b3gr5UhInGIxsowipGCMwKYnONui1QzEg0P919ASj+cbXqAGpv+8LimRKpkqLKucLL MN2/NR0xNgm4MhVJ38jTkghvveYLl4yyQcRmnE6whXzklDmuceEu3ZHmr5WsM4peZ4 N+sS3b17dUSo3NL0fOZ/whWW/9tubhtjgZcEFEcRdsdAqia0OKRS5bHVtEVy/uU3xD iATRhGUhVqJyeBMluUilpY1mc+gDz8lDDWbGOfGBVlGfUgOWNYMm6Jqwdl4CqI4M7w ffoX0BzGxYxYQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CB5E118005B for ; Wed, 7 Feb 2024 09:30:29 -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.8 required=5.0 tests=BAYES_00,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_H2,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-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.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 ; Wed, 7 Feb 2024 09:30:29 -0800 (PST) Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3bfefa7de6aso21783b6e.0 for ; Wed, 07 Feb 2024 09:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707326976; x=1707931776; 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=6s1193F5nsemk+q5vA4soIantASwmTkXsnm6Ymw1pzA=; b=PAMoaocd4OG6PXqrJs0VG3cHvxALK31Ovvg6By0aPkT+s2WU+mSyCyk7EWYuOYQ4Tj 0NIrzGbUasQSNtRrSU4kyegfz/JT/B9qioGavxLTvxFcd+/CLpot3djhxnnpiJG9tSdv F7r/075LxKrGz9Ajxb/sgz1Jm3o28OcfSkgIqXkodbuK6Q5xA23KeoMVFTevFWwSjKAL 7ykT+oBM6XEvIuay7GlwNuYhrfy5VaF1Hmlc3mindqlyzyvVXdsEGhsGcPfhi4e9JRB9 ncqum26DSJwfoZrN7D/nMxspvsAqOryqPwsoE5p8nr3fGlRanMIqN5qjzAgJ90TI0srj lNVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707326976; x=1707931776; 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=6s1193F5nsemk+q5vA4soIantASwmTkXsnm6Ymw1pzA=; b=JjWJW8kebQLXVuRcIywHq3PjogCRYyiMSYOVEac/qvg4JON51dyeIq+xVpY8lKB+EF TEfE8neORtHiv+2hs7yeZFCSyH+dGDW3gJdyUBf93m6EdtGaEZ5ijMW0GjFaMjNXIW1N eUmffIa4k7QimzznnXSBA9CIbBgdfqRKO6kYXVD8gzz7TYMbetptxSvu4kPXk0kJq2qS ReKUaVQleAfGYp4RHFa3B86OqgDIPmKJ6e20WKWJ+Kt8iTi222Sf4aF5vT65rAEMTeBg VrAeyg+e2R2Qek4Qox/Z/cmy2BMtRmH9c+NTVU4pYfhYA5CbVF2Znt0GftDKG+aHK2rp yPdg== X-Gm-Message-State: AOJu0YySE3qVepN2gnDtU8qHo+3jiNSPHPVgk+GDMw1ZA8GxAfDCS6+v K3I4nQD4H9oaPB9HMY4Xh4kWTfZn0rQpMOdciybnYjbCIPyNEZ1vyFwEDq98XubxVfUAR3nk6ZJ GjWDDebnZFgmhZhBxQ+vHXks0uIEF3LSmK3VlAgtQ X-Google-Smtp-Source: AGHT+IGMi2KQfnzkIRbwlXrq/oMRHCCSFLw1pGYFZoVJHdu7n7EvIyu/zOL+DlXK2a73X346I58z08vcCh+u1kgo9nE= X-Received: by 2002:aca:1202:0:b0:3be:323:c03f with SMTP id 2-20020aca1202000000b003be0323c03fmr84935ois.16.1707326975640; Wed, 07 Feb 2024 09:29:35 -0800 (PST) MIME-Version: 1.0 References: <742f202d-7990-4f51-b903-7a15e3fd33c2@app.fastmail.com> <1cd8fa7b-ab62-4563-bf13-bb7801f1ce8d@app.fastmail.com> In-Reply-To: <1cd8fa7b-ab62-4563-bf13-bb7801f1ce8d@app.fastmail.com> =?UTF-8?B?Yg==?= <6562680@gmail.com> Date: Wed, 7 Feb 2024 20:28:58 +0300 Message-ID: To: Larry Garfield , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000e608b90610ce0923" 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==?=) --000000000000e608b90610ce0923 Content-Type: text/plain; charset="UTF-8" I still don't understand why the problem is signature and moving a simple throw statement to return type, and then rewriting the catch statement to oneline-r. I am completely satisfied with the php way of working with method signatures except non-critical cases: - still no `undefined` type, so some functions have limited functionality with func_num_args() inside - no languages still implement emptiness check on argument types. empty string should always be additionally asserted, like positive-negative numbers, and nan/inf with float stuff (nan/inf is too rarely case) - I'd say generics support but it is fully covered with phpdoc. use argument Generic, mark it as class-string and @template and it works well Try/catch statements don't scare me. I feel the trouble in missing try/catch statements and requirements to check all method call places once you throw a non-critical error just because another way, sorry, necessary way, is too hard for fast implementation. That trouble arrives only when you move from single-task script to multi-task script. The nearest example is SQL, which always works with rows and never returns one value, response is always "list of rows". So the primary method of error handling should be focused on batch processing, but `throw` keyword is very handy for filters, assertions, validators and low level static functions. If you finish your code fully covered with exceptions - once you try to run several times the same with try/catch over method calls - the original action code could have been better by catching some exceptions on its own. However, it is closed to you and now if you want to break it into two parts, you will have to rewrite it completely, because it is completely closed to you and the slightest exception that was not caught in itself (and not in you) will break it entirely, and will not disable part of it. The exception was invented in order to shift the closure of the problem to the next level of developers. However, it is the exception that prevents these developers from changing the source logic of the code that throws it and continuing to perform the action intended in the source code - the exception simply breaks the entire branch (following `encapsulation`). This means it should break only the most primitive functions that can be replaced quickly. This is where the so-called SOLID came from, which forces everything to be broken down into molecules instead of first closing the problem and then deciding whether to break it into parts or leave it that way. --000000000000e608b90610ce0923--