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.
That's just life of a C++ programmer: you second guess everything, and there are still optimization you haven't tried, and pitfalls you haven't got into
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.
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.)
19 Comments
MyTurtleSwimsUpsideDown@fedia.io · 40 pts · 1y
KairuByte@lemmy.dbzer0.com · 16 pts · 1y
So one understood the assignment.
Lembot_0004@discuss.online · 40 pts · 1y
eager_eagle@lemmy.world · 28 pts · 1y
that's why c++ gets bullied
Lembot_0004@discuss.online · 7 pts · 1y
eager_eagle@lemmy.world · 20 pts · 1y
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.
SpaceNoodle@lemmy.world · 6 pts · 1y
It is a method!
eager_eagle@lemmy.world · 3 pts · 1y
thanks
leo85811nardo@lemmy.world · 2 pts · 1y
That's just life of a C++ programmer: you second guess everything, and there are still optimization you haven't tried, and pitfalls you haven't got into
leo85811nardo@lemmy.world · 1 pts · 1y
CanadaPlus@lemmy.sdf.org · 14 pts · 1y
Until the next person with a slightly different mental way of defining things comes along. Or just a future version of you.
mkwt@lemmy.world · 5 pts · 1y
But when you do shoot yourself in the foot, it blows your whole leg off.
Lembot_0004@discuss.online · 2 pts · 1y
iAvicenna@lemmy.world · 1 pts · 359d
Actually
https://neshobademocrat.com/stories/man-accidentally-shoots-his-foot-with-shotgun,121925
marcos@lemmy.world · 16 pts · 1y
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.
TeamAssimilation@infosec.pub · 3 pts · 1y
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.
melechric@lemmy.world · 8 pts · 1y
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.)
eager_eagle@lemmy.world · 14 pts · 1y
a logical skeuomorphism, how eccentric
mobotsar@sh.itjust.works · 3 pts · 1y
Haha! I had the same thought.
joyjoy@lemmy.zip · 10 pts · 1y
Thank goodness for the JIT and compiler optimizations.
isVeryLoud@lemmy.ca · 1 pts · 1y
...would JIT optimizations even help here?
anton@piefed.blahaj.zone · 7 pts · 1y
If those are normal integers, the compiler optimizes that to a simple compare and branch/cmov.
eager_eagle@lemmy.world · 2 pts · 1y
for others - https://godbolt.org/z/osaKrxsPx