- What is your evaluation of the proposal?
+1. These should absolutely be added.
- Is the problem being addressed significant enough to warrant a change to Swift?
Yes. Improving readability and code clarity should be a fundamental goal of language improvements.
- Does this proposal fit well with the feel and direction of Swift?
Yes. I follow the Law Of @soroush , which says that if an extension meets any one of the following four criteria, it deserves to exist:
- Does it increase expressivity?
- Does it decrease noise?
- Does it include a performance optimization?
- Does it belong on every instance of the type?
This proposal meets all four of these criteria, so I believe it belongs in the standard library.
It increases expressivity because using isEven
or isOdd
or isMultiple()
is far clearer in code than a modulo expression. It's easier to understand what the code is doing, and what the expectation of the result should be.
It decreases noise, because it removes the use of not-commonly-used operator (%
) which is harder for new programmers to understand. (Because, among other reasons, you cannot option-click an operator in Xcode to get documentation on it)
It includes a performance optimization, because of the difficulty in implementing a correct "is odd" function ā this is a burden your typical developer should not have to care about.
Finally, this belongs on all integers, because all integers can answer the question "is this number even", "is this number odd", or "is this number a multiple of the provided number".
Because of this, these extensions should absolutely exist, and the resulting huge gains in code expressivity mean they should have a place in the standard library.
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
I have been following the thread.