[m-rev.] for review: add int32.clamp/3
Julien Fischer
jfischer at opturion.com
Wed Mar 4 18:49:19 AEDT 2026
On Wed, 4 Mar 2026 at 16:31, Peter Wang <novalazy at gmail.com> wrote:
>
> On Wed, 04 Mar 2026 16:02:50 +1100 Julien Fischer <jfischer at opturion.com> wrote:
> > On Wed, 4 Mar 2026 at 15:47, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> > >
> > > On Wed, 4 Mar 2026 12:13:37 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> > > > For review by anyone.
> > >
> > > Sorry for the late review, but I didn't have a chance until now.
> > >
> > > > Add int32.clamp/3.
> > >
> > > I would prefer for this function to have a more expressive name;
> > > clamp_into_range, perhaps.
> >
> > I'm not overly fussed. clamp is the usual name for this operation in
> > programming languages that provide it, so I went with that.
> > Peter, do you have a preference?
> >
>
> clamp is the usual name. I would go with that.
>
> I have used the name clamp_to_range before, in an attempt to avoid the
> argument order confusion.
I would note that Haskell avoids this by using a tuple for the range:
clamp :: Ord a => (a, a) -> a -> a
Julien.
More information about the reviews
mailing list