On 06/26/2010 05:39 AM, WANG Cong wrote: > On 06/26/10 00:11, Neil Hodgson <nyamatongwe+thun...@gmail.com> wrote: > >> WANG Cong: >> >>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP, >>> this is and should be implemented by inherence. >> >> Most object oriented programming languages starting with Smalltalk >> have allowed adding attributes (addInstVarName) to classes at runtime. > > > Thanks, I have to admit that I know nothing about Smalltalk. > >>From what you are saying, Smalltalk picks a way similar to setattr() in > Python? Because you mentioned 'addInstVarName' which seems to be a > method or a builtin function. If so, that is my point, as I mentioned > earlier, switching to setattr() by default, instead of using assignments > by default. :) > >> Low level OOPLs like C++ and Delphi did not implement this for >> efficiency reasons. >> > > Hmm, although this is off-topic, I am interested in this too. C++ does > have metaprogramming, but that is actually static metaprogramming (using > templates), not dynamic metaprogramming here. I am wondering if > efficiency is the only reason why C++ doesn't have dynamic > metaprogramming,
Yes, it is. I'm not quite sure how far RTTI actually goes, but I know that performance is a key issue in the design of C++. If you have a look at the developments toward C++0x, you will see that many new features are being proposed - C++ is an expert's language, designed to give an expert the most powerful tool possible, with the restriction that no new feature may have a negative performance impact on an existing feature. Adding actual dynamism would have a massive impact on performance and is thus, for C++, not acceptable. > since C++ is a static programming language I think if > this limits C++ to implement its dynamic metaprogramming actually... > > Thanks. > -- http://mail.python.org/mailman/listinfo/python-list