@@ -42,33 +42,33 @@ popular languages which have kept the majority of C operators but dropped these
42
42
## Disadvantages of These Operators
43
43
44
44
1 . These operators increase the burden to learn Swift as a first programming
45
- language ( or in other cases where you don't already know these operators from a
46
- different language) .
45
+ language - or any other case where you don't already know these operators from a
46
+ different language.
47
47
48
- 2 . Their expressive advantage is minimal, e.g. ` x++ ` is not much shorter
49
- than ` x += 1 ` . The later is also more clear to a reader.
48
+ 2 . Their expressive advantage is minimal - ` x++ ` is not much shorter
49
+ than ` x += 1 ` .
50
50
51
51
3 . Swift already deviates from C in that the ` = ` , ` += ` and other assignment-like
52
- operations returns Void (for a number of reasons). These operators are
52
+ operations returns ` Void ` (for a number of reasons). These operators are
53
53
inconsistent with that model.
54
54
55
55
4 . Swift has powerful features that eliminate many of the common reasons you'd
56
56
use ` ++i ` in a C-style for loop in other languages, so these are relatively
57
- infrequently used in well-written Swift code. These include features like
57
+ infrequently used in well-written Swift code. These features include
58
58
the ` for-in ` loop, ranges, ` enumerate ` , ` map ` , etc.
59
59
60
60
5 . Code that actually uses the result value of these operators is often
61
61
confusing and subtle to a reader/maintainer of code. They encourage "overly
62
62
tricky" code which may be cute, but difficult to understand.
63
63
64
- 6 . While Swift has well defined order of evaluation, any code that dependend on
64
+ 6 . While Swift has well defined order of evaluation, any code that depended on
65
65
it (like ` foo(++a, a++) ` ) would be undesirable even if it was well-defined.
66
66
67
67
7 . These operators are applicable to relatively few types: integer and floating
68
68
point scalars, and iterator-like concepts. They do not apply to complex numbers,
69
69
matrices, etc.
70
70
71
- 8 . Having to support these could add complexity to the forthcoming Swift 3
71
+ 8 . Having to support these could add complexity to the potential
72
72
revised numerics model.
73
73
74
74
Finally, these fail the metric of "if we didn't already have these, would we add
@@ -84,18 +84,18 @@ common cases), and remove them completely in Swift 3.
84
84
85
85
## Alternatives considered
86
86
87
- Two alternatives : we could keep them. More interesting to consider, we could
87
+ Simplest alternative : we could keep them. More interesting to consider, we could
88
88
change these operators to return Void. This solves some of the problems above,
89
89
but introduces a new question: once the result is gone, the difference between
90
90
the prefix and postfix form also vanishes. Given that, we would have to pick
91
- between unfortunate choices:
91
+ between these unfortunate choices:
92
92
93
93
1 ) Keep both ` x++ ` and ` ++x ` in the language, even though they do the same
94
94
thing.
95
95
96
96
2 ) Drop one of ` x++ ` or ` ++x ` . C++ programmers generally prefer the prefix
97
97
forms, but everyone else generally prefers the postfix forms. Dropping either
98
- is deviating from C.
98
+ one would be a significant deviation from C.
99
99
100
100
Despite considering these options carefully, they still don't justify the
101
101
complexity that the operators add to Swift.
0 commit comments