you are viewing a single comment's thread
view the rest of the comments
[+] 36 points 1 year ago (13 children)
  • [–] 16 points 1 year ago (1 child)

    Yeah, just to say it more clearly: that kind of thing is why lots of people out there insist that operator overloading is a bad idea.

    And yeah, it's a C++ thing that mostly doesn't happen in other languages.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 1 year ago

    Sincerely agree. Explicit is better then implicit, that’s a general engineering axiom.

    Instead of overloading and making the next maintainer hunt for overloads, a clearly named function that does the critical steps would make the code immensely more maintainable. C++ is C gone wild.

  • source
  • parent
  • [–] 8 points 1 year ago

    Yes. Sometimes you're limited by the hardware you're controlling. This code is a bit hard to justify with that excuse though. Normally your code would do a read from hardware to see if the value decremented and then repeat the write. (Possibly a sleep/yield in there if required.)

  • source
  • parent
  • [–] 27 points 1 year ago (9 children)
  • [+] 7 points 1 year ago (8 children)
  • [–] 19 points 1 year ago (3 children)

    yes, but in this particular case I wouldn't want to second guess my decrement operation just happens to also be calling the white house or whatnot. Just make a method.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 5 points 1 year ago (2 children)

    But when you do shoot yourself in the foot, it blows your whole leg off.

  • source
  • parent
  • hideshow 2 child comments