[swift-evolution] Reconsider ++ and -- operators removal and prevent other well-known operators from change
Vanderlei Martinelli
vmartinelli at alecrim.com
Mon Feb 1 16:27:43 CST 2016
Well... I continue writing code with Swift 2.2 and I'm not loving the fact
I cannot use ++ or -- anymore (and no, I'm not using the operators in
loops, I mean things like responding to UIPageViewController data source,
etc).
And what if we remove `+=` and `-=` as well? It's so C... What if can write
code with COBOL-style like this?
ADD 1 TO MY-AWESOME-VARIABLE.
SUBTRACT 1 FROM MY-AWESOME-VARIABLE.
And look that we are not adding a `WORKING-STORAGE SECTION` or a `PROCEDURE
DIVISION` here...
Do not take it seriously, OK? It was just a joke (a bad taste joke,
perhaps). ;-)
-Van
On Sun, Jan 31, 2016 at 10:39 PM, Jonathan Tang <jonathan.d.tang at gmail.com>
wrote:
>
>
> On Sun, Jan 31, 2016 at 6:19 AM, Tino Heth via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> I do not know how far the Swift is to the adolescence, but it is certain
>> that teenagers are rebels. There's something very good at it. In most cases
>> they are to be certain. But in some things they regret later.
>>
>> Children have to learn their own lessons — and I guess re-adding "++"
>> wouldn't be as complicated as a big tattoo on your neck ;-)
>>
>> My first thought on the removal was "we'll see many custom post-increment
>> operators soon", and that may be true; but in the meantime, I came to the
>> conclusion that I won't define those custom operators, but rather configure
>> my system to replace "++" with " += 1":
>> Typing the old operator is definitely faster, but I don't mind if it's
>> turned into something else automatically (when there is no performance gain
>> for pre-increment, I've always preferred the post-variants).
>>
>>
>>
> FWIW, Python has no ++ and -- operators (you have to use += 1 or -= 1),
> and nobody misses them there. Once you introduce for-each loops, about 99%
> of the usage sites for ++ disappear, and it quickly fades out of your
> muscle memory.
>
> It used to get re-introduced every so often by having to work with C,
> Java, and Javascript, but now ES6, Java, Objective-C, PHP, Python, Ruby,
> Go, Rust, and even C++ all have for-each loops or iteration blocks, so
> there's basically no need for regular for-loops or increment operators in
> any language but C.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160201/36cbba84/attachment.html>
More information about the swift-evolution
mailing list