On Fri, 2007-10-26 at 23:03 +0400, Tomash Brechko wrote: > On Sat, Oct 27, 2007 at 03:06:21 +1000, skaller wrote:
> > And what do you do if you do not KNOW what the storage class is, > > which is the case 99.99% of the time in C++ member functions? > > I'm not quite sure what you mean here. If extern vs static---that's > of no concern. What matters is whether the object can possibly be > accessed from another thread, and this has nothing specific to C++. Yes, but with a class: struct X { int x; void f() { if (C) x = 1; } void f2() { reg = x; if (c) reg = 1; x = reg; } }; X global; void k() { X local; global.f(); global.f2(); local.f(); local.f2(); }; you would have to assume all member variables were accessible to another thread when generating the member functions, even if the variable is private, unless you did heavy analysis to ensure the class didn't leak its address. In effect this means method access is slower than global functions in a threading context.** [** in Felix I attempt to generate a global function instead of a class for a Felix function, which is a C++ applicative object .. but then Felix is a whole program analyser so it can do this. The reason is .. that I guessed C++ compilers such as gcc optimise global functions better than methods.] -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net