Previous | Next --- Slide 7 of 45
Back to Lecture Thumbnails
cube

Would the second example, if compiled, result in the compiler compiling to the first example because they're equivalent except for overhead cost, or is it too hard for a compiler right now?

iZac

@cube This depends on compiler optimization. I do not think a decent compiler (as of now) would end up compiling to the first example. It is a hard problem for a compiler to solve and might just do what programmer has asked him to do.

amaliujia

@cube, they cloud. Actually it depends how conservative compiler designers are. If they don't want to make mistakes on misunderstanding programmer's intention, they would make very limited optimization.

grose

Sure, but isn't it an obvious optimization to always use the main thread of control if it's doing nothing else?