by donatj · 2y ago · 0 comments
I still don't understand why they aren't in a package, or better yet why they didn't just make math.Min and math.Max generic?
Shadowing is better than the very questionable decisions made by whoever wrote Windows.h...
#include <Windows.h>
#define NOMINMAX // comment out to break
#include <algorithm>
auto main() -> int
{
return std::min(42, 1337); // may break
}I don't know Go, but my first thought would go to lol no generics. Now that they do have generics I guess they could do it, but backwards compatibility may require them to use other names than `math.Min` and `math.Max`.
(Note: Go did have some generic built-in constructs from the start, and could have included `min` and `max`, similar to how OCaml did it. At the same time, you don't want too many primitives in your language if you can help it.)