4 ms·
"In real life, the boy may actually be a better programmer than the girl.” I think in real life the boy will shoot himself in the leg without knowing the order
by toksaitov 15y ago
"In real life, the boy may actually be a better programmer than the girl.”
I think in real life the boy will shoot himself in the leg without knowing the order of evaluation in C.
- screwt 15y agoI'm worried that the girl will leave a loaded shotgun for someone else to shoot themselves in the leg by writing code that relies on order of evaluation rather than by using parantheses. The girl clearly knew her stuff, but I'd be much happier if she prefaced this example by also saying "it's dangerous to write code like this because...". I wouldn't want to work with someone who writes code that relies on all the features discussed in the C examples.
- SamReidHughes 15y agoHow would one write code that depends on order of evalution, instead of using parentheses? Where can you use parentheses that lets you write code that doesn't depend on order of evaluation? I think you missed something here because nothing about the example at hand has anything to do with the use of parentheses.
- Dylan16807 15y agoI'm actually worried the girl's going to shoot herself in the leg. void foo(void) { int a = 41; a = a++; printf("%d\n", a); } She says 'a gets an undefined value' but that's not true at all. There are compilers that will look at that undefined function and omit the entire body, including the print. It is extremely important to understand that undefined behavior can and will break everything, even if it appears to be behaving whenever you look.