20 years of C code, and I never knew its block scope rather than function scope. Now need to forget this new knowledge and return to sanity
if(condition) { int some_damn_thing_i_only_care_about_in_this_case = expensive(); do_thing(…); } else { whatevs(); }
-
-
so, you save 32/64 bits, at the cost of extra typing and the possibility that future readers of your code will misunderstand it?
-
Tweet unavailable
-
but are the bits saved? Is there a new stack frame for the new block? Or is scope just enforced regardless?
-
guess it depends on how clever your compiler is, don't see any reason they couldn't be but implementations ¯\_(ツ)_/¯
-
I worry about all this effort to replace programmer skill with 'clever' compilers. How long before gcc is self-aware?
-
in what fashion have you demonstrated that it presently is not
-
gcc is reasonably polite, ergo not self-aware. We all know that sentience and snark are inexplicably linked
@okayultra - 1 more reply
New conversation -
-
-
and I'm only thinking the bits are saved because I'm thinking the stack might be modified, which I suspect it isn't
-
yeah i dunno, deeper compiler shit than i tend to worry about
-
I suspect it's going to differ from compiler to compiler too.
-
one is forced to suspect
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.