It might be an absolutely adequate method. Imagine that is C++. operator-- is overloaded and controls some machinery. You can't just command capacity = currSize. Process is important.
that's why c++ gets bullied
That is why it is loved: it allows you to use ideas/objects the same way as you do as an engineer. Super cool.
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.
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.)
So one understood the assignment.
a logical skeuomorphism, how eccentric
Haha! I had the same thought.
Thank goodness for the JIT and compiler optimizations.
...would JIT optimizations even help here?
If those are normal integers, the compiler optimizes that to a simple compare and branch/cmov.
It might be an absolutely adequate method. Imagine that is C++. operator-- is overloaded and controls some machinery. You can't just command capacity = currSize. Process is important.
that's why c++ gets bullied
That is why it is loved: it allows you to use ideas/objects the same way as you do as an engineer. Super cool.
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.
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.)