Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128575 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 3E6F81A00BC for ; Wed, 27 Aug 2025 16:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1756313208; bh=w+9hXxpUdtfavR0YxuOkreJPjvvCrql3TcY1BbZzwHc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=R+BkpKkI5B2hYRqhciTdOu8ek+m+ERYPUp/UFy2Qc40FbhxXTmDAjIrKcTPsloiV2 lX9MwD1NHtqnygsRany7msefHfOseTHm/HBjeFMl37pefKKZNAbjLWPxdPPCIuL9QC ebdjKZGbzNkPAZycajdo8tEm4b9xUEJc/NG+mGdQYKMwTLPDD7RlVJX4tKozQTFrvj mEASlxlDRIqQdSZybx0vernh9ZixSWDgJMDLQeZnCYit2EwAth+LpaaRtxSgOFarXb 03MB/zN9G5b22JnybMN9ThwbOVrEgrVS4QxunLFBdyJTjkDKhFIYP/Gj3veja44mgH RWPn8tCBAK54Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B229180032 for ; Wed, 27 Aug 2025 16:46:48 +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=-1.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03olkn2103.outbound.protection.outlook.com [40.92.57.103]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 27 Aug 2025 16:46:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=psPEH9s5t4muDqE87rCQK+xfKMvEK1acBunXMUJ4IJ1rfWIqNoSdMWsmYHgdJvOXlND5NRR88QZl+/85K+38Inm7Z5OtSrpztMAve2LluY7VRFgQVhrh2aei2tKQR5XucLrWz5Ignnbk/1LOhLcv64wjRFnXLj4/79Mx0eUrvP0GIWQ9yobtnSwNgdxmIymn9/HlJTxv4uwAcKxmlYtbA+6O7/kQ3YMs5IlFTErtHl5VDrZSP88A7N0kV1sduog+SMxd6y0PqchDUfP3X+f5fZT1qPA1vRBgPWj0LWNbZ4aUHXBf9pdyXD0XHzyiZ5PD4ahyp4RDCLXl3S+LTkDHow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8BrDX5uMGCXAIMoXNSeTgriwqMniXUfsMi+XiesT5Ho=; b=b8C6NH9bZ2Zw01NvZ9yzp/0Jea+INGaLLTdWphgeFHjCVDQ3o7swkxvCd0voOG/O69H43P18nh3f1tZMbeRc/V18TUrpSOf4bAc3jhN4xc1NyHecTD3UvdNamWb8upu4r76rPcMjlhsi7U38VmYc9eygEzt9MVizMhLWw9mzA5c0pqYqN7SaAbGbSAg235u/fYzygiriaMlPy+UumTLC+KB1hWzhlFwxHdJ5PLEZJMZOEJ/cr9VLNmlrgzb293tn1tcJnf1QyNrBG4P69aoERV/VC3of3cmYMiJAFkZoQ7tc0I5k0Rl6MEMZtVpwY3sXcX5qS0ftTblgt5pmkgfG9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8BrDX5uMGCXAIMoXNSeTgriwqMniXUfsMi+XiesT5Ho=; b=R5RHAv/od++OrUAbIk2djnZrl98pT0cXbB89AmyMJw/6oUYNwiCFCyyOXPBmKfuIGB95UYREpQoRsLBmObTFWEEl8U/WvGRWZccvuUq1EKP05lqEQUHt8sEuezBr5i5yuNScuqpF1MF6U8zZNIQhJusUEB9dyB+Y0EczGz5GQINEEMKM/ry4WzoGsHSamOijjher90DRpMv+cQ+WhN8/E/Scwu0lyaYnieeA10fKOX+4sof61zCepON6pCcmd1WEV1JB+BGuQOAzaRitov+JtRQE3T6hyCPvm1BdbpwCbmKx8oKOtMTuth46dAU8ntCAUG3n65qGQ6kgQ2Q08IpOVg== Received: from AM8P250MB0170.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::21) by DB4P250MB0829.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:38e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9052.20; Wed, 27 Aug 2025 16:48:17 +0000 Received: from AM8P250MB0170.EURP250.PROD.OUTLOOK.COM ([fe80::651e:bbd2:b18a:80ff]) by AM8P250MB0170.EURP250.PROD.OUTLOOK.COM ([fe80::651e:bbd2:b18a:80ff%6]) with mapi id 15.20.9073.010; Wed, 27 Aug 2025 16:48:17 +0000 Message-ID: Date: Wed, 27 Aug 2025 18:48:16 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] [Discussion] Add clamp function To: Larry Garfield , php internals References: <090b74db-6e29-489e-870e-4c1e336c7746@app.fastmail.com> Content-Language: en-US In-Reply-To: <090b74db-6e29-489e-870e-4c1e336c7746@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AS4P190CA0023.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5d0::9) To AM8P250MB0170.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::21) X-Microsoft-Original-Message-ID: Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8P250MB0170:EE_|DB4P250MB0829:EE_ X-MS-Office365-Filtering-Correlation-Id: 7451e66e-1873-476e-b7ad-08dde5898589 X-MS-Exchange-SLBlob-MailProps: YfhX3sd/0TVWrg+fxRScxfg9v9HXnUFlvtnb1pc2lDzYYDPBhms1VIcwAH+8IoX0NAFyB2s6fT4fgB629nz+nlx0ma0C/m+QfwvsVBcrnSyxgaYxgjp0UCugJ5w5ots9khvHrpfZfncEEiQpOnKVBIx1cSE2pFA1t8gfbuvlx6Wm8inHL/jAPGTYIoGMcX/mKYEn2iK2S0LZceHESYa/5c0WAfzsoXXgOJT7eLCZN9EYV0yyUY+xSKNNZ2R288LGU/vnOHGbAUar9sSuDR1Md+mJybUzt1sU3qjjNsAR5zfOw2vblzsFJSZweVc3ikBIA+nutTl+G5DpFFDDByMluFKQ/uZSUXYr9UfE0tIsaszYiWrjRmIE6oE/vBLhklevwPW2yO+pFKIjyRSxwMH5FlRzW36XyTQkxukn1HklIlKYaYGETIkjBfkL/4FpyedhUpTkmF76lXxxscuUI34NsWtzieiEnbmIFdjmVQvwzFnddZ6zpeC5fxrIze4DD0xQZl8j8KUbA5tMAcSXXJY7132bzoRNSKNaVQPZsSBbNn7Wlwr6TZcgJb4mzV/RgH0Oc4453Bv1eF+2ILob7ZmdIdTVjsFIfshDAoqc1xKyNYlCxiTQ3d/KPgDYpnImzhqtJb55YsbZF6ZKG7Rf83FMqbuCbFuev+wD9fucDpTxh7AYSCvdt2V3ga2MFw/PeBAmSAhsXhqB2xcuT62KTJNATVkN9V4Pt10woR5CEKiWaksjNIDnqMdp0rOigQfXyTgUsKYIfxRs99AiiUd3o59A+2z1HK6ZXMS1BF8Wq1x56rU= X-Microsoft-Antispam: BCL:0;ARA:14566002|8060799015|6090799003|5072599009|15080799012|23021999003|19110799012|461199028|10035399007|3412199025|40105399003|440099028|4302099013|26104999006|12091999003|1602099012; X-Microsoft-Antispam-Message-Info: =?utf-8?B?R3RzK1FHSXZ0em1xY3FXcGVMdTdYZkVYZS83c3l4SEprZGFXR3c5MHBjSzRX?= =?utf-8?B?RUU5bWpHZ29SYjFNaUdwbm5HOCttYzFrSU1lbERYbEI0RGZYWGtMQzN3a28r?= =?utf-8?B?cGM5REprMmFDTklnV0NhS1k0ZFdRcjB5UHI0S0ovZEVSaDhHK2pucG9UekpM?= =?utf-8?B?WlZ4T3JrU3E0U0Nub3B6MWRad2pLa21xR2lIaDFyN2RpbHBLQW9sc3VLN0hS?= =?utf-8?B?VXNZeFNnRkJyLzVnaEFGS2RUZVpBbFI3VEVCN050R2l6YzJ3d3RuM0RIZkxS?= =?utf-8?B?Uk9oMCs2Tm1TczV5aW1WZ1I3SVNGaGYxUUdqeCtRK2FjcEw3dDB4Rk1ZM3Nh?= =?utf-8?B?M2RHaUdFc3JkeWpJM0VwV090T2FqVCtIOXZkN3RGN2JjTXNmWm1BeFIxTGRU?= =?utf-8?B?MUlRSGhaMDBPWU40VVJBczRhWnlOK3NaQ05aOEEySmkybzVWMWQrdGEyTGtz?= =?utf-8?B?MG1jMzEwNnlSYys5UXZYRnIycWM1K0xPQVdoWTZrUG5JSWxWZmUvYXJseXRq?= =?utf-8?B?dWVmSlhzN1ZKa2lPc3FDaGVCdzZlTnpyaGFGT3ZaL1FZcnBJVzVDZ1VKdzlT?= =?utf-8?B?QzQzWXQ0YkpDaml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5aWhr?= =?utf-8?B?akU2djhpamtpNzNseGUydnVjNmRlWTJZaE00K29kaGN6YUF1N0JwQVNSdGs2?= =?utf-8?B?aC92NWdPWS91VFArTWNZbU9TZktRZTAyYzB2eFpEN2NtRUNlUHRuZ2YweXpI?= =?utf-8?B?ZStNNUcwaDZKdHVIdFJYNzVReHNicVVVMzRsaE55c1dybzFzZ2ZieDd0U0Rx?= =?utf-8?B?eVV6cFpzakoxazBNb251ZWZPbElKREpIaGpjVlRBaGhuOUdYN1pkTWdrOEls?= =?utf-8?B?Q0hOS011S0dCS1loNGtJc0R1RzNYV0VBNDl0TnN3Rmt6YVBadjkyQ1Mza2pZ?= =?utf-8?Q?P5mjDQLFD+QMnEtNW8=3D?= X-OriginatorOrg: sct-15-20-8534-15-msonline-outlook-5f066.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 7451e66e-1873-476e-b7ad-08dde5898589 X-MS-Exchange-CrossTenant-AuthSource: AM8P250MB0170.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2025 16:48:17.4993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4P250MB0829 From: bobwei9@hotmail.com (Bob Weinand) Thanks Larry! On 27.8.2025 18:40:51, Larry Garfield wrote: > On Wed, Aug 27, 2025, at 11:06 AM, Bob Weinand wrote: >> Hey, >> >> On 27.8.2025 15:34:53, Kyle Katarn wrote: >>> Hello, >>> >>> I handled the feedback received on the draft RCF https://wiki.php.net/rfc/clamp_v2 >>> >>> If I didn't forget anything this should be now ready for discussion. So I updated its status. >>> >>> There is an implementation proposal: https://github.com/php/php-src/pull/19434 >>> And some draft for documentation here: https://github.com/php/doc-en/pull/4814 >>> >>> Thanks, >> >> As others have noted before, what's the motivation of having the >> to-be-clamped value as first parameter rather than infixed between min >> and max? >> >> E.g. from CSS: https://developer.mozilla.org/en-US/docs/Web/CSS/clamp: >> >> `clamp(min, val, max)` >> >> Feels to me as the most natural order, too. >> >> >> >> You mention it was taken from the first RFC, but that one also did not >> discuss the ordering in the first place either. > Some quick data points from momentary googling: > > CSS: clamp(min, val, max) > > Python: clamp(val, min, max) > C++: clamp(val, min, max) > Java: clamp(val, in, max) > Javascript: clamp(val, min, max) > C#: clamp(val, min, max) > > Kotlin: val.clamp(min, max) (as an extension function) > Ruby: val.clamp(min, max) > > So it looks like CSS is the oddball here. We should follow the clear majority approach. (Kyle, feel free to include this in the RFC.) > > --Larry Garfield Indeed, that makes sense then. I must admit that I've only ever been using the clamp from CSS, but never from other languages. (I still think value in the middle makes more sense, but I guess that's me then, and I won't object.) Then yes, please note it in the RFC :-) Bob