Re: [RFC] [Discussion] Add clamp function
Hi
There's precedent in ext/random with the Randomizer::getFloat() method that takes a Random\IntervalBoundary enum to decide on the the interpretation of the boundary values. Translated to clamp() this could mean:
If it weren't living in the Random extension, that very Enum could have been used.
Indeed. Back when introducing the enum, we actually had a discussion about naming and “placement”. In the end, we opted to make it ext/random-specific as a more conservative choice. I think back then it was the first native enum.
See https://externals.io/message/118810#118910 and https://chat.stackoverflow.com/transcript/11?m=55444127#55444127.
If a new general-purpose IntervalBoundary enum is introduced, I'm happy to widen the type in ext/random from \Random\IntervalBoundary to \IntervalBoundary|\Random\IntervalBoundary (and deprecate the latter in one of the following versions).
Best regards
Tim Düsterhus
Thread (22 messages)