CanadaHonk / proposal-math-clamp

A TC39 proposal to add Math.clamp
https://canadahonk.github.io/proposal-math-clamp/
MIT License
39 stars 1 forks source link

Argument order #2

Closed Richienb closed 7 months ago

Richienb commented 2 years ago

Should the number be the first argument and the range be the next two or should the range be the first and third with the number in the middle?

Richienb commented 2 years ago

We'll copy the order for the css function of the same name https://developer.mozilla.org/en-US/docs/web/css/clamp

Richienb commented 10 months ago

https://github.com/Richienb/proposal-math-clamp/pull/3#discussion_r1455444602

The parameter order in the draft JavaScript version is (value, min, max), whereas the CSS version is (min, value, max), which is quite confusing.

The CSS version's prioritization of the minimum value is based on accessibility needs in CSS practices. However, this behavior might not be easily mapped to general-purpose programming languages, as pointed out in this pull request. It seems to be quite inconsistent with the behavior of other programming languages.

Richienb commented 7 months ago

We're using (number, min, max) because this is how most userland implementations order them.