Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128595 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 lists.php.net (Postfix) with ESMTPS id BAA4D1A00BC for ; Fri, 29 Aug 2025 21:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1756501825; bh=cqh5Wna8pbgVX01p9TWSWPwBxxF20epXDj60dW3yV2M=; h=Date:Subject:To:References:From:In-Reply-To:From; b=mGkbYd5ybX8I2WzxuCLqnlkcAFS8lqK4ROvsntOG/Eu7blvmWtMx9Lz39BkZta3pT MBqfB1lI30nyhuwuELB/LHpgai1+j+IboeKF+FmxCU8tv5yRM9geU18/ywa0JYhRJo idn9n2jGaY7LrtHTMyzZqGPDUFlG7EI8ePLfl1pxzyg/3ByhhCbJEjjhOshu7nT2t3 FZqDO8d/O6U3yTxDw8YuluokPxR5AH6D6E1pS9Ri+hdi64YTqhSI9QxSpsQPzfT3tC Sn1h58Wxcv7rH55zMbdxA1DQllD2RyYcHTnBmWiEXMj1MW/bbI4udmx+1W5xWMDgZ6 1iSXxP96hwkMg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B55B0180086 for ; Fri, 29 Aug 2025 21:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from alcott.smtp.mailx.hosts.net.nz (alcott.smtp.mailx.hosts.net.nz [43.245.52.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 29 Aug 2025 21:10:22 +0000 (UTC) Received: from 122-57-11-211-adsl.sparkbb.co.nz ([122.57.11.211] helo=[192.168.1.67]) by alcott.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1us6Nv-006xsi-0R for internals@lists.php.net; Sat, 30 Aug 2025 09:11:47 +1200 Message-ID: <93d89063-b7ae-4266-a3b8-90c06117c1a3@varteg.nz> Date: Sat, 30 Aug 2025 09:11:39 +1200 Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] [Discussion] Add clamp function To: internals@lists.php.net References: <1756361767126.3727989781.4204927711@yahoo.de> <3b1bd29cd42074b499d38e10cb97bf42@bastelstu.be> <4db81c8b-64ee-4bf6-9134-c233c8cb3f71@varteg.nz> Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Hosts-DKIM-Check: none From: weedpacket@varteg.nz (Morgan) On 2025-08-30 01:10, Tim Düsterhus wrote: > Hi > > On 8/29/25 04:42, Morgan wrote: >> Another part of the argument is "complexity", as brought up in the >> original proposal. I notice that the offered implementation of this >> function relies entirely on zend_compare(). > > I'm not finding the word “complexity” in https://wiki.php.net/rfc/clamp > or https://externals.io/message/115050. Can you link to the message you > are referring to? > I'm probably misremembering https://externals.io/message/128505#128532 and #128542. >> reasons. The extra complication may not be worth it if there are only >> two or three values being compared (long and double are the first types >> zend_compare tries). > > I'm positive that the benchmarks will answer that question. > Agreed. But if clamp doesn't need to special-case numeric inputs to perform well then maybe max/min don't either (at least not any more) and their implementations could be streamlined. > Best regards > Tim Düsterhus