Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126929 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id D4A131A00BC for ; Tue, 25 Mar 2025 05:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742881863; bh=W6pSjQkE+W6hho4xig/RiABawrHaG39aqMFDkW8//vM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=XUAj5WnUnJnRrgCk/63vunaA+JfO8Xaqijr4+oFrtTkLTOMgS3HPEfo7OpPJwwEgu ad+lNLM8mqwVjDIk2xuY3Z+qZBHCU+L6WhdwRTlV6mSLC9QwcI71PNHtujrwz8G/4c FUI63IJoxxmpoT3xWPdeKDrWtXf2veN/tOfYfaeK0zo+y0Yj9/JiDhNmyezzNUZpo8 KYB2Pqs2wufV8by0tBf99xUBEWFHa0W1rVREUzWL4JrMznvo7cWNVmXedzcVdxypjM vLELKtgBfzqnfBEoEzVRC+bWoxjLI1mVoPaDrnOkDF2d97FHfJKTMEuwLJh4M4CK64 h5j2pUhCaLb5A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 73C47180053 for ; Tue, 25 Mar 2025 05:51:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,FORGED_MUA_MOZILLA, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: <010f0195cbdcf6cc-8ef65563-7a6b-41d5-88e2-feccb9ff1921-000000@mailer.miqrogroove.com> Received: from e226-6.smtp-out.us-east-2.amazonses.com (e226-6.smtp-out.us-east-2.amazonses.com [23.251.226.6]) (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, 25 Mar 2025 05:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qxgm6rwwab7twixglbexlc5btumk6x2k; d=miqrogroove.com; t=1742882010; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=W6pSjQkE+W6hho4xig/RiABawrHaG39aqMFDkW8//vM=; b=tmzxB7vQjkDjvb+Vw6Qvp75td/IeFhbdbeV9XMbLvItWO4B+ZJFx7c6xVq3SpOoR 1BsD/nNlWeeEgx1q5Zrfa0u5IU8+7zH6hO6MBnEYLrfAGHGcQJl4M0OJIRgx+ayYdV/ 6ShZ0bEwzDw1alk5pCXRc0kv3GGUeERyyGNOA7iD5rAnAcAqn1f6m1oCEY1M6wi1Sa+ Nn5XYR4PQqf+nQlMju8Dbm5FVHb5h8Kw7oS/Qe3LkCLWUOLUTKfThbQtNzjedlJimdG JlkoudyYZR4KS8LdL9gYJTbEr3Bzi1nwscr0gCKS5Me0zki3sr5y/6vZDvWZcfGseMb 7AQkQwUrwQ== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=xplzuhjr4seloozmmorg6obznvt7ijlt; d=amazonses.com; t=1742882010; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=W6pSjQkE+W6hho4xig/RiABawrHaG39aqMFDkW8//vM=; b=l5FofllCTYbGkg7rFO2Pvqs4pg+QckgFtr90LIpEIIjnrxFQxtrOnUlbgBD8LEqB q74bzFE8RkbFH623tmnOH4FpFr+slSJ06Fr0SbGK4911VkVwp88QyiN29R/BKBIYNL4 jqFawJ5IDk/dLyejmHYxa+xZFJ7NwBZybrMOywOA= Authentication-Results: solid; auth=pass (plain) Message-ID: <010f0195cbdcf6cc-8ef65563-7a6b-41d5-88e2-feccb9ff1921-000000@us-east-2.amazonses.com> Date: Tue, 25 Mar 2025 05:53:30 +0000 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Feedback for nullc Idea To: internals@lists.php.net References: <010f0195c30f8ccb-c7fa839e-ec18-4613-9851-9d96b943dca2-000000@us-east-2.amazonses.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=miqrogroove.com; s=jan2022; h=subject:from:to; bh=W6pSjQkE+W6hho4xig/RiABawrHaG39aqMFDkW8//vM=; b=ndzzKU8BHwqo1DvI8qc9T1ggCgrc1/J7sok+rK0sX64Mg+HemzUXC+8cz8I+fbTQ6tEEU/NSGA NPS+B+x2Rb4dBsaa/ZqZHcGWT1ntUdMEhBltjdXpFqe9ucP/P6yGFr/j/DG1hFdx5ygNqAEoxdus 17qF08InO4BzX3M2xfv7xlmaOl67IHed0nU7b23jjUWW5rsUn/UK3oc0NUjYNVrdHKxWOu0l2pGm LNz9Y43QF01dVaoNWMEtHy36jrQ2bGSwH9Ri+Eg//BSxy4vxBiyNVL5Pt3QX3w2OOrLY+M5vIDsR NTYGbiRfTtgcqPcjcutVHsLmazF1ONvAKhfnQTUw== Feedback-ID: ::1.us-east-2.QbD2JL3ZnDgkTsZd92lLMWNtgKUB27BqpIzxIe67R3Y=:AmazonSES X-SES-Outgoing: 2025.03.25-23.251.226.6 From: php@miqrogroove.com (Robert Chapin) On 3/23/2025 11:10 AM, Larry Garfield wrote: > I'm not sure it justifies a new pseudo-function language construct. Fair enough.  Thank you for the feedback. On 3/23/2025 2:37 PM, Rowan Tommins [IMSoP] wrote: > It's telling that all your examples with ?? put a value other than > null on the right-hand side. I may have over-simplified the examples.  Comparing $input === 'yes' will have the same result whether $input is null or 'none' or an empty string.  So not implying a result type, just want to compare a literal or other variable to $input even when not declared. A different example could be if (coalesce($_POST['tick']) > 10) return; > In my experience, a lot of people struggle to follow logic like this, > and it can easily lead to subtle bugs. Compare the same logic with > explicit defaults: > > if (nullc($test, 'off') === 'on') > if (nullc($test, 'on') !== 'off') Having optional defaults seems fine.  Meanwhile... if ($test ?? 'on' !== 'on') will evaluate to true when $test is set to 'on'. > There is a small risk that some people might have an existing function > with different behaviour, e.g. a test on "emptiness" with `$arg != > false`, and need to rename it when upgrading PHP. This is a good point.  I assume that risk exists for all new functions and needs to be considered. > I'm still only lukewarm on including it, because it's mostly just > reminding you to include a pair of parentheses: Think of it as a quick way to use an undeclared variable without having to explain operator precedence to other developers. In any case, thank you for the feedback.