Re: [PHP-DEV] Proposal: clamp

2021-06-23 Thread Ayesh Karunaratne
> Greetings internals, > > I present to you a proposal for a new basic math function: clamp. > > The main goal of this function is to contain a number inside a given bound. > And return the number if it is inside of that bound, and if not, and the > number is outside of the given bound, the

Re: [PHP-DEV] Proposal: clamp

2021-06-23 Thread Ilija Tovilo
Hi Kim > I present to you a proposal for a new basic math function: clamp. > ... > What are your opinions on this function? I for one think this is a good candidate for PHPs standard library. It's simple, unopinionated and standardized in other languages. Even though it's simple to implement in

Re: [PHP-DEV] Proposal: clamp

2021-06-23 Thread Pierre
Le 23/06/2021 à 10:28, Lynn a écrit : On Wed, Jun 23, 2021 at 3:07 AM Marco Pivetta wrote: The problem is exactly the fact that it is trivial to implement in userland: why not do it there instead? My 2cents: because people won't use it when the barrier is too high to get it. There are a ton

Re: [PHP-DEV] Proposal: clamp

2021-06-23 Thread Lynn
On Wed, Jun 23, 2021 at 3:07 AM Marco Pivetta wrote: > The problem is exactly the fact that it is trivial to implement in > userland: why not do it there instead? > My 2cents: because people won't use it when the barrier is too high to get it. There are a ton of great libraries that have

Re: [PHP-DEV] Proposal: clamp

2021-06-22 Thread Marco Pivetta
Hey Kim On Wed, Jun 23, 2021, 02:25 Kim Hallberg wrote: > This function is very easy to implement, has no side effects or backward > compatibility issues, unless a userland implementation already has the > function declared, > I like the function, the name, and its simplicity. The problem is

[PHP-DEV] Proposal: clamp

2021-06-22 Thread Kim Hallberg
Greetings internals, I present to you a proposal for a new basic math function: clamp. The main goal of this function is to contain a number inside a given bound. And return the number if it is inside of that bound, and if not, and the number is outside of the given bound, the nearest bound is