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

Reply via email to