why there are no multimethods in c++? [closed]

筅森魡賤 提交于 2019-12-06 19:49:16

问题


I read many article about how to implement multimethod in c++:

  1. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1529.html
  2. http://www.codeproject.com/KB/recipes/mmcppfcs.aspx
  3. http://lambda-the-ultimate.org/node/2590
  4. http://parasol.tamu.edu/people/peterp/omm/

why there are no multimethod in c++?

why do not they get supported by c++ standard?


回答1:


Straight from the horse's mouth:

"I rejected multi-methods with regret, because I liked the idea, but couldn't find an acceptable form under which to accept it."

Bjarne Stroustrup, The Design and Evolution of C++ (p297)

And later:

"Multi-methods is one of the interesting what-ifs of C++. Could I have designed and implemented them well enough at the time? [...] What other work might have been left undone to provide the time to design and implement multi-methods?"

(p298f)

In general, whenever you feel the urge to know why some particular C++ feature was implemented, or was not implemented, or was implemented the way it is now, and if that feature pre-dates the standardization, you want to read D&E.




回答2:


As Bjarne has pointed out a number of times, when people criticize C++, it usually runs something like: "C++ is too big, too complex, has too many features, and it's too hard to learn -- you should really work at making it smaller and simpler. Oh, and while you're working on that I also have this really great idea for a killer feature that you should add!"




回答3:


Just because it could be done doesn't mean it's a problem that it wasn't done. One criticism of C++ is along the lines of "Stroustrup took everything anyone had heard of, and tried to include it."

Plus, as Raymond Chen says, "Every feature starts off with -100 points." That is, before you ask why C++ doesn't have these things, you should explain in detail why it needs them. Otherwise your feature stays in negative territory, due to the costs associated with it.



来源:https://stackoverflow.com/questions/4844669/why-there-are-no-multimethods-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!