1. 20
  1.  

  2. 9

    dotnet tag?

    1. 4

      You’ll have to pay extra for it. ;)

    2. 4

      Is x++ really as bad as he is making it out to be?

      1. 9

        No.

        That point is actually complaining about assignment expressions (including postfix and prefix increment, decrement, arithmetic assignment and just regular assignment) returning values, which enables all sorts of idiotic constructs and stupid errors. I am entirely behind these operators not returning values. However, the pre/postfix inc/decrement operators are no worse than arithmetic assignment in this regard, and are extremely convenient.

        (As an aside, if the inc/decrement operators don’t return, post/prefix no longer carries semantics, which wipes out the rest of the author’s complaints about them.)

        1. 1

          Makes sense, thanks for the clarification.

        2. 2

          Yes.

          1. 3

            What if ++x; were removed from the language and x++; stayed? Would that still be bad?

            Forgive me, but I fail to see any real-life scenario where using x++ to increment could cause a bug…

            1. 3

              I’ve definitely seen bugs caused by someone habitually using one or the other by default when there’s no reason to do otherwise, and somebody else not noticing that it wasn’t the one they personally default to. Neither is more problematic than the other, but it’s a dimension of variation that creates cognitive overhead, and at best its utility is only to make things slightly terser.

              It’s not really practical to remove from a language that has it, both for compatibility reasons and because it would upset people significantly. But it’s definitely a praxis issue that I think is important for designers of new languages to understand. I am definitely in the school of thought that considers the need for an idiom to be a serious design smell, and a feature that invites two overlapping idioms is just asking for trouble.

              1. [Comment removed by author]

                1. 8

                  That’s an odd complaint. Neither x += 1 nor x = x + 1 is any more atomic.

                  1. 1

                    But it isn’t async, so that shouldn’t be an issue in practice (right? That’s how it seems to me but I don’t want to sound like I am dismissing it as an impossibility).

                    The part about them returning value makes sense though, but if you removed that and the distinction between x++ and ++x you should be good, right?