Re:The C23 edition of Modern C is now available for free
by uecker on Tuesday October 15, 2024 @03:39PM
(#41852319)
Function overloading is a feature that makes code less self-documenting without providing any meaningful value. Operator overloading is more interesting, because you can build you domain language with nice syntax. But I also tend to think that this is not really worth it.
Re:The C23 edition of Modern C is now available for free
by adamrezich on Tuesday October 15, 2024 @05:25PM
(#41853276)
In C++ where you have methods? Sure. It would be nice to have in C, though. But, alas, ABI compatibility.
Re:The C23 edition of Modern C is now available for free
by listeria on Wednesday October 16, 2024 @09:11AM
(#41858696)
Function overloading enables the building of powerful idioms like swap, operator== and this [1] proposal for composable hashing to name a few. And when combined with templates (and ADL to provide some encapsulation with namespaces) you can build some interesting abstractions akin to the io module in go, like this implementation of io.ReadFull():
template<typename R>
constexpr ssize_t
io::ReadFull(R reader, char *buf, size_t len)
{
ssize_t recvd = 0, ret;
do {
ret = read(reader, &buf[recvd], len - recvd);
if (ret > 0)
recvd += ret;
else
break;
} while (recvd < len);
return recvd;
}
---1: https://open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3980.h...
Another big one that I always forget C still doesn't support is function overloading.