On Wed, 2012-04-18 at 06:03 +0800, Chiheng Xu wrote: > > > Sorry, I don't know what is the benefit of const ivars.
I didn't say there's a benefit of using const ivars in this hypothetical case. It's just another possible option of doing certain things. > But if you use "tree->code" instead of "tree->code()", the compiler > know very well whether you intend to read or write a piece of memory. > The const-ness is clear. I doubt how the compiler optimizer can > further optimize it. I didn't say that either... > By saying "efficient", I probably mean compile time is reduced( macro > expansion + optimizing, or inlining + optimizing, are avoided). > I also probably mean reduced .h file size( the definitions of accessor > macros and C++ getter/setter inline methods, are avoided). > ...then probably I wasn't aware of the fact that this is about optimizing for compile time. If that's the case, maybe the topic of the thread should be changed to avoid further confusion. Cheers, Oleg