[RFC v1 2/2] c: Add _Maxof and _Minof operators
Alejandro Colomar
alx@kernel.org
Wed Oct 15 18:01:16 GMT 2025
Hi Paul,
On Wed, Oct 15, 2025 at 01:14:07PM -0400, Paul Koning wrote:
>
>
> > On Oct 15, 2025, at 12:10 PM, Michael Matz <matz@suse.de> wrote:
> >
> > ...
> >> And as we're seeing, bool belongs in a third class of integer types, in
> >> which it is the only member. It doesn't belong in the class of unsigned
> >> integer types (which is BTW something under discussion in the
> >> C Committee at the moment).
> >
> > If saturated types are ever included it won't be the only member of that
> > class. Even absent that the loneliness of bool doesn't imply anything
> > specific.
>
> I don't see how saturation, or the lack of it, is relevant. "max" and "min" are defined in terms of the < operator, so any type for which < is defined can define min/max as well. Python is an example of a language that does this uniformly (for example, max("abc","abxq") is valid).
>
> I take it that the C standard says < is defined for boolean type. That's all the answer that seems needed. Conversely, in a language where < is not a valid operator for booleans (such as ALGOL) min/max would not be, either.
The _Maxof and _Minof operators we're discussing are unrelated to MAX(3)
and MIN(3). MAX(3) and MIN(3) return the maximum or minimum of two
numbers. _Maxof() and _Minof() return the maximum or minimum
representable value of a type.
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20251015/b8c2776c/attachment.sig>
More information about the Gcc-patches
mailing list