[swift-evolution] Reconsider ++ and -- operators removal and prevent other well-known operators from change
Vanderlei Martinelli
vmartinelli at alecrim.com
Sat Jan 30 13:13:53 CST 2016
Hello. I also like the alternative: keep ++ and -- while returning void. :-)
On Sat, Jan 30, 2016 at 5:00 PM, Will Stanton <willstanton1 at yahoo.com>
wrote:
> Hello Van,
>
> I think you make some good points about readability, and I do not recall
> the retention of ‘++’ and ‘--' being discussed much, perhaps since SE-0004
> and 0007 were accepted. All the same:
>
> At first, I really disliked the removal of ++ and --. In my opinion, the
> first three disadvantages in SE-0004 (
> https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md)
> were not that strong:
>
> > These operators increase the burden to learn Swift as a first
> programming language - or any other case where you don't already know these
> operators from a different language.
>
> ‘++’ does not seem less obvious than ‘+=’ and learning about the 2-4
> extra operators doesn’t seem burdensome.
> ++ and -- are also not particularly rare (I remember being surprised that
> Python did not support them)
>
> > Their expressive advantage is minimal - x++ is not much shorter than x
> += 1.
> Still, `++` is easier to type than `+= 1`
>
> > Swift already deviates from C in that the =, += and other
> assignment-like operations returns Void (for a number of reasons). These
> operators are inconsistent with that model.
>
> I liked the alternative considered: keep ++ and -- while returning void
>
>
>
> But over a few days I became less bothered by the proposal. I agreed with
> this:
> > Swift has powerful features that eliminate many of the common reasons
> you'd use ++i in a C-style for loop in other languages, so these are
> relatively infrequently used in well-written Swift code. These features
> include the for-in loop, ranges, enumerate, map, etc.
>
>
> I respectfully disagree with removing the operators but also don’t have
> strong objections.
>
> Regards,
> Will Stanton
>
> > On Jan 30, 2016, at 1:12 PM, Vanderlei Martinelli via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > Hello everybody.
> >
> > I see Swift as a member of “C family" (a granddaughter/grandson of C, a
> daughter/son of Objective-C). OK, she/he is different and has her/his own
> personality like a daughter/son should be and have, but I still like to see
> Swift and recognize some traces that I know are things that became from C.
> >
> > This said, I would like to say that after the removal of `++` and `--`
> my code becomes less readable and more prone to errors. There were two
> characters to differentiate an addition from a subtraction, now there is
> only one (`+= 1`, `-= 1`). Also the character keys are very close in the US
> keyboard so it is easier to make a mistake and is not as simple as the
> previous solution when I typed two times the same key. Using Erica's way of
> saying certain things: I do not love the removal of `++` and `--`.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160130/173c5408/attachment.html>
More information about the swift-evolution
mailing list