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