Link: Manually disable catch-all min()/max() overloads for arrays by bradcray · Pull Request #19288 · chapel-lang/chapel · GitHub
Merge pull request #19288 from bradcray/disable-gen-min-max-for-arrays
Manually disable catch-all min()/max() overloads for arrays
[reviewed by @mppf]
Our catch-all min/max overloads don't work when promoted due
to the lack of support for promoted conditionals in Chapel; but if
they're disabled for arrays, things work as you'd expect (by promoting
the scalar versions designed for specific types). So here, I disable
array arguments from falling into the general min/max case to permit
elementwise min/max on arrays.
In undertaking this, I considered broadening the filter to look for other
promotable types like ranges and domains, but (a) I didn't have any good
motivation for adding support for those cases (e.g.,
doesn't seem like an interesting computation, and while
max(-10..10 by 2, -5..5) is a bit more interesting, it's not much), and
(b) I wasn't sure where to draw the line (e.g., I could imagine a user type
that supported promotion but also supported comparison operators).
So this felt like a simple, obvious step forward where additional refinements
may want to be made over time.
This makes me wonder a bit about what more we could do as
language/library designers to make such catch-all overloads more
constrained; or what practices we should use as library developers
to avoid such cases.
Modified Files: A test/library/standard/Math/minMaxArr.chpl